Expression class¶
(Shortest import: from brian2 import Expression)
- class brian2.equations.codestrings.Expression(code=None, sympy_expression=None)[source]¶
Bases:
CodeStringClass for representing an expression.
- Parameters:
code : str, optional
The expression. Note that the expression has to be written in a form that is parseable by sympy. Alternatively, a sympy expression can be provided (in the
sympy_expressionargument).sympy_expression : sympy expression, optional
A sympy expression. Alternatively, a plain string expression can be provided (in the
codeargument).
Attributes
Stochastic variables in this expression
Methods
Split the expression into a stochastic and non-stochastic part.
Details
- stochastic_variables¶
Stochastic variables in this expression
- split_stochastic()[source]¶
Split the expression into a stochastic and non-stochastic part.
Splits the expression into a tuple of one
Expressionobjects f (the non-stochastic part) and a dictionary mapping stochastic variables toExpressionobjects. For example, an expression of the formf + g * xi_1 + h * xi_2would be returned as:(f, {'xi_1': g, 'xi_2': h})Note that theExpressionobjects for the stochastic parts do not include the stochastic variable itself.- Returns:
(f, d) : (
Expression, dict)A tuple of an
Expressionobject and a dictionary, the first expression being the non-stochastic part of the equation and the dictionary mapping stochastic variables (xior starting withxi_) toExpressionobjects. If no stochastic variable is present in the code string, a tuple(self, None)will be returned with the unchangedExpressionobject.