-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
solvers: Fixed NoneType Error #18324
Conversation
✅ Hi, I am the SymPy bot (v149). 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.6. 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.
Update The release notes on the wiki have been updated. |
Please review the PR @jksuom @oscarbenjamin . |
Codecov Report
@@ Coverage Diff @@
## master #18324 +/- ##
=============================================
+ Coverage 75.002% 75.536% +0.534%
=============================================
Files 649 643 -6
Lines 167347 167325 -22
Branches 39418 39440 +22
=============================================
+ Hits 125514 126392 +878
+ Misses 36299 35403 -896
+ Partials 5534 5530 -4 |
sympy/solvers/tests/test_solveset.py
Outdated
@@ -178,6 +178,14 @@ def test_issue_11536(): | |||
assert solveset(0**x - 1, x, S.Reals) == FiniteSet(0) | |||
|
|||
|
|||
def test_issue_17882(): | |||
equation = solveset(-8*x**2/(9*(x**2 - 1)**(4/3)) + 4/(3*(x**2 - 1)**(1/3)), x, S.Complexes) | |||
equation = str(equation) |
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.
We should avoid using str
for testing.
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.
Should I implement an alternative approach??
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.
Use rational numbers for the coefficients, like S(4)/3
. You should be able to compare the solution exactly.
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.
Can you rewrite the equation in the required way, so that I get a better idea?
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.
Specifically, you should write the equation like
solveset(-8*x**2/(9*(x**2 - 1)**(S(4)/3)) + 4/(3*(x**2 - 1)**(S(1)/3)), x, S.Complexes)
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.
It looks like the issue is not resolved 'well'.
If you just want to stop investigating further and get over with the unevaluated result like
ConditionSet(x, Eq(-8x**2(x2 - 1)(-1.33333333333333)/9 + 4*(x2 - 1)(-0.333333333333333)/3, 0), S.Complexes)
, I would merge this soon.
But I would rather update the original post and keep the thread open, and make sure that it should resolve
- Some logic that leads to infinite recursions
- It should actually 'solve' the equation rather than returning conditionset.
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.
Actually, it looks like this is not resolving anything because your original test case
solveset(-8*x**2/(9*(x**2 - 1)**(4/3)) + 4/(3*(x**2 - 1)**(1/3)), x, S.Complexes)
works as same in the master.
It looks like you should actually get
solveset(-8*x**2/(9*(x**2 - 1)**(S(4)/3)) + 4/(3*(x**2 - 1)**(S(1)/3)), x, S.Complexes)
to work
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.
Ok, no issue.
But in my opinion, we can merge this and keep the thread open for further improvements.
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.
No, unfortunately for the reason in #18324 (comment)
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.
ok, i didn't observe this, i will start working on this immediately.
@jksuom in the original issue: #17882, was regarding a Nonetype error, but since the issue is already resolved, should we go ahead with this PR, and try to get: |
It seems that sympy/sympy/solvers/solvers.py Line 3448 in f3c949f
I think that
|
whre eq = Now after the above mentioned change by @jksuom, the issue is resolved. |
@jksuom shall i go ahead with this or anything else needs to be changed? |
This is causing testcases to fail in solvers\ode.py |
This is caused due to change in return type of unrad() |
The equations of ode.py involve derivatives. Those are removed from
|
Still one testcase is failing: |
It looks like more conditions have to be added. That
It might be possible (or necessary) to use an even more restrictive condition like |
Now the tests are passing, but the same error is occuring: |
@jksuom please review the PR, if any changes are required please suggest otherwise the PR is ready to be merged. |
Thanks, I think it is ready. |
Fixes #17882
Closes #18026
Brief description of what is fixed or changed:
Fixes an error in solvers.solvers.unrad() where it would return a
TypeError: cannot unpack non-iterable NoneType object
Unrad() now returns the simplified numerator even when there are radicals left in the denominator, but since the numerator is free of radicals it seems logical to return the simplified numerator.
Example:
Used to return:
TypeError: cannot unpack non-iterable NoneType object
Now returns:
1) (4*x**2 - 12, []) and 2) FiniteSet(sqrt(3), -sqrt(3))
Other comments:
Added tests
Release Notes: