sympy_conversion¶
- wrenfold.sympy_conversion.from_sympy(expr: Basic | MatrixBase, sp: module | 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 used.
- Returns:
The closest equivalent expression.
- Raises:
TypeError – When a sympy object has no equivalent in wrenfold.
- wrenfold.sympy_conversion.to_sympy(expr: Expr | MatrixExpr | BooleanExpr, sp: module | None = None, evaluate: bool = True) Basic | MatrixBase ¶
Convert expression tree to sympy expressions.
- Parameters:
expr – Scalar-valued expression.
sp – The sympy module. If None, the
sympy
package will be used.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.