From e1deca1ef145e37456c4f2da5a380fbfd1f2fc0a Mon Sep 17 00:00:00 2001 From: mstimberg Date: Thu, 18 Jul 2013 22:57:46 +0200 Subject: [PATCH] Final fix for the linear state updater, should now work with sympy 0.7.2 and 0.7.3 --- brian2/stateupdaters/exact.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/brian2/stateupdaters/exact.py b/brian2/stateupdaters/exact.py index 7d9b7be16..dfb2a7cdb 100644 --- a/brian2/stateupdaters/exact.py +++ b/brian2/stateupdaters/exact.py @@ -237,8 +237,8 @@ def __call__(self, equations, specifiers=None): dt = Symbol('dt', real=True, positive=True) A = (matrix * dt).exp() C = sp.ImmutableMatrix([A.dot(b)]) - b - S = sp.MatrixSymbol('_S', len(variables), 1) - updates = A * S + C.transpose() + _S = sp.MatrixSymbol('_S', len(variables), 1) + updates = A * _S + C.transpose() try: # In sympy 0.7.3, we have to explicitly convert it to a single matrix # In sympy 0.7.2, it is already a matrix (which doesn't have an @@ -247,11 +247,11 @@ def __call__(self, equations, specifiers=None): except AttributeError: pass - # The solution contains _S_00, _S_10 etc. for the state variables, + # The solution contains _S[0, 0], _S[1, 0] etc. for the state variables, # replace them with the state variable names abstract_code = [] for idx, (variable, update) in enumerate(zip(variables, updates)): - rhs = update.subs('_S_%d0' % idx, variable) + rhs = update.subs(_S[idx, 0], variable) identifiers = get_identifiers(sympy_to_str(rhs)) for identifier in identifiers: if identifier in specifiers: