-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Fix simplification of Eq(pi/L, 0) to None from False with L positive #16027
Conversation
✅ Hi, I am the SymPy bot (v137). 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.4. Note: This comment will be updated with the latest check if you edit the pull request. You need to reload the page to see it. Click here to see the pull request description that was parsed.
|
@asmeurer please review. |
Some of the tests will fail because I was not sure whether we should return |
Eq should not return None. It should either reduce to True or False, or remain unevaluated. |
@asmeurer please review. |
sympy/core/tests/test_relational.py
Outdated
@@ -17,7 +17,7 @@ def test_rel_ne(): | |||
|
|||
# issue 6116 | |||
p = Symbol('p', positive=True) | |||
assert Ne(p, 0) is S.true |
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.
These tests should be kept. We still want that behavior.
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.
For the current master:
>>> from sympy import *
>>> from sympy.core.relational import Ne
>>> p=symbols('p')
>>> assert Ne(p, 0) is S.true
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AssertionError
>>>
But, I don't know how its clearing the tests. Can you please check it once.
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.
p must be positive.
from sympy import Ne, Symbol, S
p = Symbol('p', positive=True)
gives:
In [8]: Ne(p, 0) == S.true
Out[8]: True
In [9]: Ne(p, 0) is S.true
Out[9]: True
The thing is that if you change the tests you must be sure that the new behavior is the behavior you want.
sympy/core/tests/test_relational.py
Outdated
@@ -92,7 +92,7 @@ def test_Eq(): | |||
|
|||
# issue 6116 | |||
p = Symbol('p', positive=True) | |||
assert Eq(p, 0) is S.false |
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.
This too. The new test doesn't really test the same thing.
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.
similar behaviour here as well.
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.
In my current master:
In [1]: from sympy import Eq, Symbol, S
In [2]: p = Symbol('p', positive=True)
In [3]: Eq(p, 0) is S.false
Out[3]: True
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.
ohh thanks, I was missing the positive
.
You must keep all the old tests. I only commented explicitly on a few. The whole idea is to be able to simplify in certain cases. While you are correct in that the simplification you point out should not be simplified, it cannot lead to that other which should are not simplified (unless there are some really good arguments for that). |
@oscargus please review. I've modified the tests only for |
@@ -693,19 +694,19 @@ def test_issue_10401(): | |||
|
|||
assert Eq(1/(1/x + 1), 1).func is Eq | |||
assert Eq(1/(1/x + 1), 1).subs(x, S.ComplexInfinity) is S.true | |||
assert Eq(1/(1/fin + 1), 1) is S.false | |||
assert Eq(1/(1/fin + 1), 1).subs(fin, 1) is S.false |
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.
The problem with using subs here is that you change the test from testing if the method can determine that this is false just based on the properties of fin
to testing if 1/2 is equal to 1. Which is not the same thing.
Same holds for all other tests where subs is added.
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.
so, should we use func
??
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.
I don't understand why you've changed these tests at all.
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.
You should try to avoid changing tests unless you know for sure that it is wanted, not only to make the test pass, but because the test was wrong/the behavior changed. So just leave all tests as is and possibly add new tests for #12690
References to other Issues or PRs
Fixes #12690
Brief description of what is fixed or changed
previously:
After the fix:
Other comments
Release Notes