Skip to content

Commit

Permalink
Merge pull request #1062 from brian-team/fix_#1061
Browse files Browse the repository at this point in the history
Correctly deal with -inf in equations
  • Loading branch information
mstimberg committed Mar 22, 2019
2 parents c429811 + 4304711 commit 2f55eba
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
6 changes: 5 additions & 1 deletion brian2/core/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import sympy
from numpy.random import randn, rand
from sympy import Function as sympy_Function
from sympy import S

import brian2.units.unitsafefunctions as unitsafe
from brian2.core.preferences import prefs
Expand Down Expand Up @@ -644,4 +645,7 @@ def timestep(t, dt):

DEFAULT_CONSTANTS = {'pi': SymbolicConstant('pi', sympy.pi, value=np.pi),
'e': SymbolicConstant('e', sympy.E, value=np.e),
'inf': SymbolicConstant('inf', sympy.oo, value=np.inf)}
'inf': SymbolicConstant('inf', S.Infinity,
value=np.inf),
'-inf': SymbolicConstant('-inf', S.NegativeInfinity,
value=-np.inf)}
9 changes: 9 additions & 0 deletions brian2/tests/test_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,13 @@ def test_error_messages():
assert expected_2 in message


@attr('codegen-independent')
def test_sympy_infinity():
# See github issue #1061
assert sympy_to_str(str_to_sympy('inf')) == 'inf'
assert sympy_to_str(str_to_sympy('-inf')) == '-inf'


if __name__=='__main__':
test_parse_expressions_python()
test_parse_expressions_numpy()
Expand All @@ -493,3 +500,5 @@ def test_error_messages():
test_substitute_abstract_code_functions()
test_sympytools()
test_error_messages()
test_sympy_infinity()

0 comments on commit 2f55eba

Please sign in to comment.