New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed #22020 by checking for oo in numerical equals #22022
Conversation
✅ Hi, I am the SymPy bot (v161). I'm here to help you write a release notes entry. Please read the guide on how to write release notes. Your release notes are in good order. Here is what the release notes will look like:
This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.10. Click here to see the pull request description that was parsed.
|
May it is |
Benchmark results from GitHub Actions Lower numbers are good, higher numbers are bad. A ratio less than 1 Significantly changed benchmark results (PR vs master) Significantly changed benchmark results (master vs previous release) Full benchmark results can be found as artifacts in GitHub Actions |
I do not disagree with it. However, there may be cases where we actually want to return So either wait for a "proper" fix or go with this that will not break anything (as far as I can tell, maybe one should check for |
sympy/core/expr.py
Outdated
@@ -666,7 +666,7 @@ def check_denominator_zeros(expression): | |||
a = expr._random(None, 0, 0, 0, 0) | |||
except ZeroDivisionError: | |||
a = None | |||
if a is not None and a is not S.NaN: | |||
if a is not None and a not in (S.NaN, S.Infinity, S.NegativeInfinity): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from sympy.polys.polyutils import illegal
...
if a is not None and a not in illegals:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weirdly enough adding S.ComplexInfinity
, i.e., using illegal
(should be in a better location, right? In core somewhere?) leads to that the following test fails:
x = Symbol('x', positive=True)
e5 = (1 + x)/x
assert e5.is_constant() is False
I realize by checking the blame that I added it a while back, but do not really remember the circumstances. It is stated in the documentation that it is tested for denominators being zero. However, in this case returning None
should be more correct than False
since x
cannot be zero...
Found a better way to fix it, so I close this (as it is done in a completely different way). |
References to other Issues or PRs
Closes #22020
Brief description of what is fixed or changed
It seems like
evalf
now returnsoo
instead of throwingZeroDivisionError
for some cases. This breaks equals resulting in an error thatoo
cannot be turned into anint
.Other comments
Release Notes
is_constant()
on certain expressions which may result in division by zero.