HeldExpression
HeldExpression
HeldExpression()Methods
| Name | Description |
|---|---|
__add__ |
Add this transformer to other, returning the result. |
__call__ |
Execute a bound transformer |
__eq__ |
Compare two transformers. |
__ge__ |
Compare two transformers |
__gt__ |
Compare two transformers |
__le__ |
Compare two transformers |
__lt__ |
Compare two transformers |
__mul__ |
Add this transformer to other, returning the result. |
__neg__ |
Negate the current transformer, returning the result. |
__neq__ |
Compare two transformers. |
__pow__ |
Take self to power exp, returning the result. |
__radd__ |
Add this transformer to other, returning the result. |
__rmul__ |
Add this transformer to other, returning the result. |
__rpow__ |
Take base to power self, returning the result. |
__rsub__ |
Subtract this transformer from other, returning the result. |
__rtruediv__ |
Divide other by this transformer, returning the result. |
__rxor__ |
Returns a warning that ** should be used instead of ^ for taking a power. |
__sub__ |
Subtract other from this transformer, returning the result. |
__truediv__ |
Divide this transformer by other, returning the result. |
__xor__ |
Returns a warning that ** should be used instead of ^ for taking a power. |
contains |
Create a transformer that checks if the expression contains the given element. |
is_type |
Test if the transformed expression is of a certain type. |
matches |
Create a transformer that tests whether the pattern is found in the expression |
__add__
HeldExpression.__add__(other: HeldExpression | Expression | int | float | complex | Decimal) -> HeldExpressionAdd this transformer to other, returning the result.
Parameters
other(HeldExpression | Expression | int | float | complex | Decimal) The other operand to combine or compare with.
__call__
HeldExpression.__call__() -> ExpressionExecute a bound transformer. If the transformer is unbound, you can call it with an expression as an argument.
Examples
from symbolica import *
x = S('x')
e = (x+1)**5
e = e.hold(T().expand())()
print(e)__eq__
HeldExpression.__eq__(other: HeldExpression | Expression | int | float | complex | Decimal) -> ConditionCompare two transformers.
Parameters
other(HeldExpression | Expression | int | float | complex | Decimal) The other operand to combine or compare with.
__ge__
HeldExpression.__ge__(other: HeldExpression | Expression | int | float | complex | Decimal) -> ConditionCompare two transformers. If any of the two expressions is not a rational number, an interal ordering is used.
Parameters
other(HeldExpression | Expression | int | float | complex | Decimal) The other operand to combine or compare with.
__gt__
HeldExpression.__gt__(other: HeldExpression | Expression | int | float | complex | Decimal) -> ConditionCompare two transformers. If any of the two expressions is not a rational number, an interal ordering is used.
Parameters
other(HeldExpression | Expression | int | float | complex | Decimal) The other operand to combine or compare with.
__le__
HeldExpression.__le__(other: HeldExpression | Expression | int | float | complex | Decimal) -> ConditionCompare two transformers. If any of the two expressions is not a rational number, an interal ordering is used.
Parameters
other(HeldExpression | Expression | int | float | complex | Decimal) The other operand to combine or compare with.
__lt__
HeldExpression.__lt__(other: HeldExpression | Expression | int | float | complex | Decimal) -> ConditionCompare two transformers. If any of the two expressions is not a rational number, an interal ordering is used.
Parameters
other(HeldExpression | Expression | int | float | complex | Decimal) The other operand to combine or compare with.
__mul__
HeldExpression.__mul__(other: HeldExpression | Expression | int | float | complex | Decimal) -> HeldExpressionAdd this transformer to other, returning the result.
Parameters
other(HeldExpression | Expression | int | float | complex | Decimal) The other operand to combine or compare with.
__neg__
HeldExpression.__neg__() -> HeldExpressionNegate the current transformer, returning the result.
__neq__
HeldExpression.__neq__(other: HeldExpression | Expression | int | float | complex | Decimal) -> ConditionCompare two transformers.
Parameters
other(HeldExpression | Expression | int | float | complex | Decimal) The other operand to combine or compare with.
__pow__
HeldExpression.__pow__(exp: HeldExpression | Expression | int | float | complex | Decimal) -> HeldExpressionTake self to power exp, returning the result.
Parameters
exp(HeldExpression | Expression | int | float | complex | Decimal) The exponent.
__radd__
HeldExpression.__radd__(other: HeldExpression | Expression | int | float | complex | Decimal) -> HeldExpressionAdd this transformer to other, returning the result.
Parameters
other(HeldExpression | Expression | int | float | complex | Decimal) The other operand to combine or compare with.
__rmul__
HeldExpression.__rmul__(other: HeldExpression | Expression | int | float | complex | Decimal) -> HeldExpressionAdd this transformer to other, returning the result.
Parameters
other(HeldExpression | Expression | int | float | complex | Decimal) The other operand to combine or compare with.
__rpow__
HeldExpression.__rpow__(base: HeldExpression | Expression | int | float | complex | Decimal) -> HeldExpressionTake base to power self, returning the result.
Parameters
base(HeldExpression | Expression | int | float | complex | Decimal) The base expression.
__rsub__
HeldExpression.__rsub__(other: HeldExpression | Expression | int | float | complex | Decimal) -> HeldExpressionSubtract this transformer from other, returning the result.
Parameters
other(HeldExpression | Expression | int | float | complex | Decimal) The other operand to combine or compare with.
__rtruediv__
HeldExpression.__rtruediv__(other: HeldExpression | Expression | int | float | complex | Decimal) -> HeldExpressionDivide other by this transformer, returning the result.
Parameters
other(HeldExpression | Expression | int | float | complex | Decimal) The other operand to combine or compare with.
__rxor__
HeldExpression.__rxor__(a: Any) -> HeldExpressionReturns a warning that ** should be used instead of ^ for taking a power.
Parameters
a(Any) The operand passed with^; use**for exponentiation instead.
__sub__
HeldExpression.__sub__(other: HeldExpression | Expression | int | float | complex | Decimal) -> HeldExpressionSubtract other from this transformer, returning the result.
Parameters
other(HeldExpression | Expression | int | float | complex | Decimal) The other operand to combine or compare with.
__truediv__
HeldExpression.__truediv__(other: HeldExpression | Expression | int | float | complex | Decimal) -> HeldExpressionDivide this transformer by other, returning the result.
Parameters
other(HeldExpression | Expression | int | float | complex | Decimal) The other operand to combine or compare with.
__xor__
HeldExpression.__xor__(a: Any) -> HeldExpressionReturns a warning that ** should be used instead of ^ for taking a power.
Parameters
a(Any) The operand passed with^; use**for exponentiation instead.
contains
HeldExpression.contains(element: HeldExpression | Expression | int | float | complex | Decimal) -> ConditionCreate a transformer that checks if the expression contains the given element.
Parameters
element(HeldExpression | Expression | int | float | complex | Decimal) The element that should be contained in the expression.
is_type
HeldExpression.is_type(atom_type: AtomType) -> ConditionTest if the transformed expression is of a certain type.
Parameters
atom_type(AtomType) The atom type to test or require.
matches
HeldExpression.matches(
lhs: Expression | int | float | complex | Decimal,
cond: PatternRestriction | Condition | None = None,
min_level: int = 0,
max_level: int | None = None,
level_range: tuple[int, int | None] | None = None,
level_is_tree_depth: bool = False,
partial: bool = True,
allow_new_wildcards_on_rhs: bool = False,
) -> ConditionCreate a transformer that tests whether the pattern is found in the expression. Restrictions on the pattern can be supplied through cond.
Parameters
lhs(Expression | int | float | complex | Decimal) The expression to match against.cond(PatternRestriction | Condition | None) An additional restriction that a match or replacement must satisfy.min_level(int) The minimum level at which a match is allowed.max_level(int | None) The maximum level at which a match is allowed.level_range(tuple[int, int | None] | None) The(min_level, max_level)range in which matches are allowed.level_is_tree_depth(bool) Whether levels should be measured by tree depth instead of function nesting.partial(bool) Whether matches are allowed inside larger expressions instead of only at the top level.allow_new_wildcards_on_rhs(bool) Whether wildcards that appear only on the right-hand side are allowed.