split_expression function

(Shortest import: from brian2.stateupdaters.explicit import split_expression)

brian2.stateupdaters.explicit.split_expression(expr)[source]

Split an expression into a part containing the function f and another one containing the function g. Returns a tuple of the two expressions (as sympy expressions).

Parameters:

expr : str

An expression containing references to functions f and g.

Returns:

(non_stochastic, stochastic) : tuple of sympy expressions

A pair of expressions representing the non-stochastic (containing function-independent terms and terms involving f) and the stochastic part of the expression (terms involving g and/or dW).

Examples

>>> split_expression('dt * __f(__x, __t)')
(dt*__f(__x, __t), None)
>>> split_expression('dt * __f(__x, __t) + __dW * __g(__x, __t)')
(dt*__f(__x, __t), __dW*__g(__x, __t))
>>> split_expression('1/(2*dt**.5)*(__g_support - __g(__x, __t))*(__dW**2)')
(0, __dW**2*__g_support*dt**(-0.5)/2 - __dW**2*dt**(-0.5)*__g(__x, __t)/2)