Skip to content

Commit

Permalink
Final fix for the linear state updater, should now work with sympy 0.…
Browse files Browse the repository at this point in the history
…7.2 and 0.7.3
  • Loading branch information
mstimberg committed Jul 18, 2013
1 parent d8598d1 commit e1deca1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions brian2/stateupdaters/exact.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down

0 comments on commit e1deca1

Please sign in to comment.