from brian2.parsing.sympytools import str_to_sympy)
Parses a string into a sympy expression. There are two reasons for not using
sympifydirectly: 1) sympify does a
from sympy import *, adding all functions to its namespace. This leads to issues when trying to use sympy function names as variable names. For example, both
factor– quite reasonable names for variables – are sympy functions, using them as variables would lead to a parsing error. 2) We want to use a common syntax across expressions and statements, e.g. we want to allow to use
&) and function names like
expr : str
The string expression to parse..
A sympy expression
- In case of any problems during parsing.
Parsing is done in two steps: First, the expression is parsed and rendered as a new string by
SympyNodeRenderer, translating function names (e.g.
ceiling) and operator names (e.g.
&), all unknown names are wrapped in
Function(...). The resulting string is then evaluated in the
from sympy import *namespace.