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
fand another one containing the functiong. Returns a tuple of the two expressions (as sympy expressions).- Parameters:
expr : str
An expression containing references to functions
fandg.- 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 involvinggand/ordW).
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*sqrt(dt))*(__g_support - __g(__x, __t))*(sqrt(__dW))') (0, sqrt(__dW)*__g_support/(2*sqrt(dt)) - sqrt(__dW)*__g(__x, __t)/(2*sqrt(dt)))