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
replace np.isclose
for pivot selection warning
#14167
Conversation
Thanks @pmeier. Can you provide some example cases of the false positives and add a test that this resolves the problem? On the other hand, |
There are no false positives yet. There is currently a discussion in abs(actual - expected) <= atol + rtol * abs(expected) to a symmetric one (following abs(actual - expected) <= max(atol, rtol * max(abs(actual), abs(expected))) To judge the impact of such a change I ran a patched
will give warnings (and in turn test errors) like this:
Since pivval = 2
tol = 1e-9
atol = 0
rtol = 1e4
np.isclose(pivval, tol, atol=atol, rtol=rtol) # False
np.isclose(tol, pivval, atol=atol, rtol=rtol) # True Since the intent seems to be "check if abs(pivval) <= tol * 1e4 Note that this also circumvents checking the difference of
This is more future proofing this than enhancing the functionality. |
Like @mdhaber mentioned, we're in maintenance-only mode for simplex and recommend the newer HiGHS methods. However, I see no issue with accepting simple patches for simplex, so if the CI looks good I'll merge |
Thanks @pmeier but I doubt |
CI seems to be not happy, although I can't find a reason why.
I thought so too, but what I get from the discussion following my comment in numpy/numpy#10161 is that this is actually on the table.
Most definitively. The current state is to create change it in a separate namespace and slowly trickle it down to the core module.
It is actually not that bad. If we only change the definition from asymmetric to symmetric, in
Normally, I would disagree, since my patch makes it safer, easier to read, and even future proof. But since the CI seems not to be happy about it, I don't know if it is worth the effort to debug. I'll leave it up to you to close this. |
Closing for now, we can re-evaluate if the proposals for |
Reference issue
Closes #14081
What does this implement/fix?
This replaces
numpy.isclose
inscipy/scipy/optimize/_linprog_simplex.py
Lines 219 to 229 in 0617428
since it relies on the asymmetric definition. Using
np.isclose(tol, pivval)
leads to a lot of false positives, sincertol
is applied to the second argument.The change communicates the intent better and might also be safer in edge-cases.