-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Closed
Labels
Milestone
Description
We are currently looking into using a symmetric closeness definition for numpy.isclose
. To judge the impact this move would have on other libraries we ran scipy
's test suite against a modified numpy
.
While doing this a lot of tests emitted this warning
scipy/scipy/optimize/_linprog_simplex.py
Lines 219 to 229 in 0617428
# The selected pivot should never lead to a pivot value less than the tol. | |
if np.isclose(pivval, tol, atol=0, rtol=1e4): | |
message = ( | |
"The pivot operation produces a pivot value of:{0: .1e}, " | |
"which is only slightly greater than the specified " | |
"tolerance{1: .1e}. This may lead to issues regarding the " | |
"numerical stability of the simplex method. " | |
"Removing redundant constraints, changing the pivot strategy " | |
"via Bland's rule or increasing the tolerance may " | |
"help reduce the issue.".format(pivval, tol)) | |
warn(message, OptimizeWarning, stacklevel=5) |
because it relies on the asymmetric definition.
I've tracked it down to #9081 and specifically #9081 (comment) (cc @Kai-Striega @mdhaber). If I understand the intention correctly it should check if the pivval
is significantly greater than the tolerance. If that is the case
if abs(pivval) <= tol * 1e4:
...
would be a better choice, because
- it communicates the intent better, and
- is safer since
np.isclose
basically checksabs(pivval - tol) <= ...
which might lead to unwanted behavior in an edge case.