cutcutcodec.core.compilation.parse.parse_to_sympy

cutcutcodec.core.compilation.parse.parse_to_sympy(expr: str | Basic | Complex, symbols: dict[str, Symbol] = None) Basic[source]

Convert the expression in sympy compilable expression.

Parameters

exprstr or sympy.Expr

The string representation of the equation. Some operators like multiplication can be implicit.

symbolsdict[str, sympy.Symbol]

A dictionary of local variables to use when parsing.

Returns

sympy.core.expr.Expr

The version sympy of the expression.

Raises

SyntaxError

If the entered expression does not allow to properly define an equation.

Examples

>>> from cutcutcodec.core.compilation.parse import parse_to_sympy
>>> parse_to_sympy(0)
0
>>> parse_to_sympy("1/2 + 1/2*cos(2pi(t - i*j))")
1*cos(2*pi*(-i*j + t))/2 + 1/2
>>>