evaluate_expr function
(Shortest import: from brian2.codegen.optimisation import evaluate_expr)
- brian2.codegen.optimisation.evaluate_expr(expr, ns)[source]
Try to evaluate the expression in the given namespace
Returns either (value, True) if successful, or (expr, False) otherwise.
Examples
>>> assumptions = {'exp': DEFAULT_FUNCTIONS['exp'].pyfunc, ... 'inf': DEFAULT_CONSTANTS['inf'].value} >>> evaluate_expr('1/2', assumptions) (0.5, True) >>> evaluate_expr('exp(-inf)', assumptions) (0.0, True) >>> evaluate_expr('sin(2*pi*freq*t)', assumptions) ('sin(2*pi*freq*t)', False) >>> evaluate_expr('1/0', assumptions) ('1/0', False)