sympy_conversion¶
- wrenfold.sympy_conversion.from_sympy(expr: Any, sp: Any | None = None) Expr | MatrixExpr | BooleanExpr ¶
Convert sympy expressions to wrenfold expressions. This method will recursively traverse the sympy expression tree, converting each encountered object to the equivalent wrenfold expression.
- Parameters:
expr – A sympy expression.
sp – The sympy module. If None, the package
sympy
will be imported.
- Returns:
The closest equivalent expression.
- Raises:
TypeError – When a sympy object has no equivalent in wrenfold.
- wrenfold.sympy_conversion.to_sympy(*args, **kwargs)¶
Overloaded function.
to_sympy(expr: wrenfold.sym.Expr, sp: Optional[object] = None, evaluate: bool = True) -> object
Convert expression tree to sympy expressions.
- Parameters:
expr – Scalar-valued expression.
sp – The sympy module. If None, the
sympy
package will be imported.evaluate – Forwarded to sympy constructors as the
evaluate
argument. If true, sympy will canonicalize expressions.
- Returns:
Equivalent sympy expression.
- Raises:
wrenfold.sym.TypeError – If no equivalent expression type exists in sympy.
to_sympy(expr: wrenfold.sym.BooleanExpr, sp: Optional[object] = None, evaluate: bool = True) -> object
Overload of
wrenfold.sympy_conversion.to_sympy()
that acceptsBooleanExpr
.to_sympy(expr: wrenfold.sym.MatrixExpr, sp: Optional[object] = None, evaluate: bool = True) -> object
Overload of
wrenfold.sympy_conversion.to_sympy()
that acceptsMatrixExpr
.