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: modify symbols ordering in _solve_system #20928
solvers: modify symbols ordering in _solve_system #20928
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.8. Click here to see the pull request description that was parsed.
Update The release notes on the wiki have been updated. |
5e60e2e
to
cd6d25f
Compare
The release note should be for solvers rather than polys. I think it would be better to put these tests together in one place so that the code for the system and solution is not duplicated and to emphasise the fact that we are asserting that all solvers give the same results. |
Oh, whoops. Sure thing. Just put them all in |
I would put them wherever the tests for linsolve are. |
In |
492577a
to
b1af6e8
Compare
cde97b5
to
19599a9
Compare
Why is |
The test is a random test so it can potentially fail for some inputs but not necessarily in a reproducible way. |
I see. How are failed random tests like this one usually treated? Will the issue have to be debugged somehow? |
It's probably not possible to reproduce this. At the top of the test output you can see the random seed as well as the PYTHONHASHSEED which controls set ordering. In principle you can set those seeds when running the tests like:
However the random seed is not set at the start of each separate test so to actually reproduce this you would need to run the exact same tests that
That runs half of the test suite and the failing test won't come up for some time. In between other tests may or may not be skipped due to the presence or absence of different libraries or Python versions etc which might alter the random seed by the time you get to the one that failed. Without knowing what the seed was I just tried running this random test many times: from sympy.testing.randtest import (test_derivative_numerically as td,
random_complex_number as randcplx)
from sympy.functions.special.elliptic_integrals import elliptic_pi as P
from sympy import srepr
from sympy.abc import m
for i in range(10000):
print(i)
rx, ry = randcplx(), randcplx()
assert td(P(rx, ry, m), m), str((srepr(rx), srepr(ry))) I think I let it go about 5000 times and didn't see it fail once. That's why we really need to know the seed when something like this happens. There are two approaches that would help with this sort of thing in future (ideally we should do both of these):
If you feel like fixing either of those then you can push up a commit to do that. Otherwise you can close and reopen the PR which will rerun the tests and I expect that they will pass. |
I think I'll just close and reopen. I'm still working out why |
Looks like the same test failed again. Let's see what happens after another commit is pushed... |
Sure. I just added a blank line. |
c8b80ec
to
05be5f2
Compare
@oscarbenjamin,
It seems only equations with The problem is that I don't think |
No, I see that now. I think that probably the Probably nonlinsolve should pass any subsystems of linear equations to linsolve but that's a separate issue.
For now I would say add a test along with the others showing the different output that nonlinsolve gives but add code comments clearly explaining that ideally nonlinsolve would give the same outputs as the others. Then if the output from nonlinsolve changes later (e.g. because it is made to use linsolve) the test will fail but the comment will make it clear that it's okay to change the test. |
Makes sense! |
05be5f2
to
3d7cc6d
Compare
In that order? I get a TypeError saying it can't unpack a non-iterable.
Sure thing. |
Got it. |
Yes, that simplifies it. |
Sure. I kind of just copied what you wrote and modified it a bit. :) |
Which is the same? |
3d7cc6d
to
b8e2400
Compare
It looks like I accidentally commented on the commit rather than the diff in the PR. I think I was referring to |
When squashing commits in a PR it's best just to do it at the end (if needed at all). While working through it gets confusing if the commits commented on disappear and it's also helpful to be able to see any test failures etc - those disappear once you force push. |
Oh, okay. Sorry about that. I think it could probably be derived, yes. |
18ae6b8
to
e9a58f7
Compare
That force push was just some spaces I forgot to add. :) |
Okay, looks good to me. I can't merge this because it's marked as a "draft" though. |
Great. I'll update to a regular PR. |
The tests failed again due to #20933 |
Looks good |
References to other Issues or PRs
Fixes #18208
Brief description of what is fixed or changed
solve
was solving a system of equations in a different, albeit valid, way tolinsolve
. Modified the waysolvers._solve_system
sorts symbols to preserve order and keepsolve
andlinsolve
in sync.Other comments
Will be adding tests for other solvers to test the same system of equations which caused the issue.
Release Notes