Skip to content

Commit

Permalink
Fix replacements with equations without expressions (i.e. parameters)
Browse files Browse the repository at this point in the history
  • Loading branch information
mstimberg committed Nov 3, 2020
1 parent ecee6cb commit a0d0f24
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions brian2/equations/equations.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,12 +690,12 @@ def _do_substitution(self, equations, to_replace, replacement):
'this name is already used for another variable.')
# Replace occurrences in the RHS of equations
new_expr = eq.expr
if to_replace in eq.identifiers:
if to_replace in eq.identifiers and eq.expr is not None:
code = eq.expr.code
new_expr = Expression(re.sub(r'(?<!\w|{)' + to_replace + r'(?!\w|})',
replacement_str, code))
replaced_name = True
if to_replace in eq.template_identifiers:
if to_replace in eq.template_identifiers and new_expr is not None:
code = new_expr.code
new_expr = Expression(code.replace('{'+to_replace+'}',
replacement_str))
Expand Down

0 comments on commit a0d0f24

Please sign in to comment.