You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I reduced my problem to this expression: sympy.sympify('1<zoo')
Which will raise a TypeError: TypeError: Invalid comparison of complex zoo
zoo occurs during an 'accidental' division by zero that seldomly occurs. The original comparisson also has nothing to do with complex numbers: 1<1/(a-a). And, of course, this expression does not make sense.
However, I expected sympy to evaluate to 'nan' and not to crash.
Is this intentionally?
Is there a way to return 'nan' without a try-block? Or specify fail-evaluations as proposed somewhere in #5195 so I could choose a (signed) oo instead of zoo to have a secure evaluation?
.
Complete Exception:
>>> import sympy
>>> sympy.sympify('1<zoo')
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 3296, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-112-fa2832916d99>", line 1, in <module>
sympy.sympify('1<zoo')
File "C:\ProgramData\Anaconda3\lib\site-packages\sympy\core\sympify.py", line 368, in sympify
expr = parse_expr(a, local_dict=locals, transformations=transformations, evaluate=evaluate)
File "C:\ProgramData\Anaconda3\lib\site-packages\sympy\parsing\sympy_parser.py", line 965, in parse_expr
return eval_expr(code, local_dict, global_dict)
File "C:\ProgramData\Anaconda3\lib\site-packages\sympy\parsing\sympy_parser.py", line 878, in eval_expr
code, global_dict, local_dict) # take local objects in preference
File "<string>", line 1, in <module>
File "C:\ProgramData\Anaconda3\lib\site-packages\sympy\core\numbers.py", line 2185, in __lt__
return Rational.__lt__(self, other)
File "C:\ProgramData\Anaconda3\lib\site-packages\sympy\core\numbers.py", line 1818, in __lt__
return Expr.__lt__(expr, other)
File "C:\ProgramData\Anaconda3\lib\site-packages\sympy\core\expr.py", line 334, in __lt__
raise TypeError("Invalid comparison of complex %s" % me)
TypeError: Invalid comparison of complex zoo
The text was updated successfully, but these errors were encountered:
I reduced my problem to this expression:
sympy.sympify('1<zoo')
Which will raise a TypeError:
TypeError: Invalid comparison of complex zoo
zoo occurs during an 'accidental' division by zero that seldomly occurs. The original comparisson also has nothing to do with complex numbers:
1<1/(a-a)
. And, of course, this expression does not make sense.However, I expected sympy to evaluate to 'nan' and not to crash.
Is this intentionally?
Is there a way to return 'nan' without a try-block? Or specify fail-evaluations as proposed somewhere in #5195 so I could choose a (signed)
oo
instead ofzoo
to have a secure evaluation?.
Complete Exception:
The text was updated successfully, but these errors were encountered: