# str_to_sympy function¶

(Shortest import: from brian2.parsing.sympytools import str_to_sympy)

brian2.parsing.sympytools.str_to_sympy(expr, variables=None)[source]

Parses a string into a sympy expression. There are two reasons for not using sympify directly: 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 beta and 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 (instead of &) and function names like ceil (instead of ceiling).

Parameters

expr : str

The string expression to parse.

variables : dict, optional

Dictionary mapping variable/function names in the expr to their respective Variable/Function objects.

Returns

s_expr :

A sympy expression

Raises

SyntaxError

In case of any problems during parsing.