Skip to content

Commit

Permalink
Handle input containing division by zero better
Browse files Browse the repository at this point in the history
  • Loading branch information
C.A.P. Linssen committed Nov 21, 2024
1 parent 7c46b18 commit 8671f85
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion odetoolbox/sympy_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,17 @@ def _is_constant_term(term, parameters: Mapping[sympy.Symbol, str] = None) -> bo
"""
if parameters is None:
parameters = {}

assert all([type(k) is sympy.Symbol for k in parameters.keys()])
return type(term) in [sympy.Float, sympy.Integer, sympy.core.numbers.Zero, sympy.core.numbers.One] \

if sympy.__version__.startswith("1.4"):
sympy_zero = sympy.numbers.Zero
sympy_one = sympy.numbers.One
else:
sympy_zero = sympy.core.numbers.Zero
sympy_one = sympy.core.numbers.One

return type(term) in [sympy.Float, sympy.Integer, sympy_zero, sympy_one] \
or all([sym in parameters.keys() for sym in term.free_symbols])


Expand Down

0 comments on commit 8671f85

Please sign in to comment.