friendlysam.opt.Sub

class friendlysam.opt.Sub

Subtraction operator.

See Operation for a general description of operations.

Parameters:*args – Should be exactly two items to subtract.

Examples

>>> x = VariableCollection('x')
>>> expr = x(1) - x(2)
>>> expr
<friendlysam.opt.Sub at 0x...>
>>> expr == Sub(x(1), x(2))
True
>>> x(1).value, x(2).value = 2, 3
>>> float(expr)
-1.0
Sub.create(*args) Classmethod to create a new object.
Sub.evaluate([replace, evaluators]) Evaluate the expression recursively.
Sub.args This property holds the arguments of the operation.
Sub.leaves The leaves of the expression tree.
Sub.value The concrete value of the expression, if possible.
Sub.variables This property gives all leaves which are instances of Variable.