-
-
Notifications
You must be signed in to change notification settings - Fork 5.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
BUG: correct the test loop in test_arpack.eval_evec #14798
Conversation
ok, a test in GitHub Actions fails in the changed function on Linux Python 3.8:
and a different failure on Nightly CPython
and on macOS - a similar to Nightly Python failure (same test data):
|
The new failures are not from reversing the checks right, but from this piece of code have the wrong indentation for LHS = np.dot(a, evec)
if general:
RHS = eigenvalues * np.dot(b, evec)
else:
RHS = eigenvalues * evec
assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err) |
Reversing the checks makes sense to me, and the last two failures seem minor. The first one is a large change, increasing |
On Sun, Oct 3, 2021 at 4:31 PM Ralf Gommers ***@***.***> wrote:
The new failures are not from reversing the checks right, but from this
piece of code have the wrong indentation for assert_allclose(...) so it's
not run at all for general is True?
Good catch, thanks! I was puzzled by these tests passing at all. Needless
to say, I corrected the indentation, without
noticing it was wrong before.
… LHS = np.dot(a, evec)
if general:
RHS = eigenvalues * np.dot(b, evec)
else:
RHS = eigenvalues * evec
assert_allclose(LHS, RHS, rtol=rtol, atol=atol, err_msg=err)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#14798 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJXYHATGTWMYVIDY3Y4VYLUFBZO3ANCNFSM5FHNQDAA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
It's a bit suspect to me that it depends on the Python version. 3.8 is getting old, perhaps time to move on 3.9? |
We can't drop 3.8, we're only just dropping 3.7 now - 3.8 will be around for another ~1.5 years. This is also not likely to be dependent on Python version I'd say. A dbg build is a debug build of Python, so debug symbols are included. Such builds are typically also shipped in Linux distros as separate packages (typically named |
Is there documentation on how to fix a particular test?
and
|
There aren't any docs, this is too detailed to have docs. I'd say bump the test tolerance unconditionally to make the 2 tests with a small mismatch pass, and then special-case the last test based on the parameters you point out above. |
I actually find |
Agreed. I don't think that has been discussed before, at least not recently. Worth a separate follow-up. |
I am running into some sort of Heisenbug here. Namely, the 1st error in #14798 (comment) consistently reproduces on a Linux system, by running
and get one failing test. Then I apply the following change, special-casing this error, and changing tolerances for it: --- a/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py
+++ b/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py
@@ -28,7 +28,7 @@ from scipy._lib._gcutils import assert_deallocated, IS_PYPY
_ndigits = {'f': 3, 'd': 11, 'F': 3, 'D': 11}
-def _get_test_tolerance(type_char, mattype=None):
+def _get_test_tolerance(type_char, mattype=None, D_type=None, which=None):
"""
Return tolerance values suitable for a given test:
@@ -67,6 +67,14 @@ def _get_test_tolerance(type_char, mattype=None):
# sparse in single precision: worse errors
rtol *= 5
+
+ if mattype is np.asarray and type_char == 'F' and which == 'LA' \
+ and D_type.name == "gen-hermitian-Mc":
+ # missing case from PR 14798
+ tol = 30 * np.finfo(np.float32).eps
+ rtol *= 5
+
+
return tol, rtol, atol
@@ -223,8 +231,7 @@ def eval_evec(symmetric, d, typ, k, which, v0=None, sigma=None,
kwargs['OPpart'] = OPpart
# compute suitable tolerances
- kwargs['tol'], rtol, atol = _get_test_tolerance(typ, mattype)
-
+ kwargs['tol'], rtol, atol = _get_test_tolerance(typ, mattype, d, which)
# on rare occasions, ARPACK routines return results that are proper
# eigenvalues and -vectors, but not necessarily the ones requested in
# the parameter which. This is inherent to the Krylov methods, and With it, on the same system I consistently reproduce 2nd error from #14798 (comment), instead of the 1st error. This feels like something something floating point interrupts touched by NumPy... |
f100ce5
to
e33ed07
Compare
OK, I've bumped whatever was needed |
I think I've fixed everything I could (some test pipelines crash for unrelated reasons). |
@dimpase the change to the PROPACK submodule was a mistake I assume? |
indeed, sorry, I seldom work with submodules - and this change does not show up in "normal" git. |
somehow scipy/PROPACK#1 got mixed in. |
it's a pure evil - the submodule update got mixed into d6f6eec - nothing and nobody told me this happened... |
Yes this happens often unfortunately, if you change branches and then forget to re-run |
|
macOS tests fail while building
The rest passes. |
I tend to rely on |
In scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py, eval_evec one tests for correctness eigenpairs, in a loop, which is meant to allow for an error (the `k`-tuple of eigenpairs found differs from what's asked by `which` argument) in Krylov subspaces method. Cf. comments there: # on rare occasions, ARPACK routines return results that are proper # eigenvalues and -vectors, but not necessarily the ones requested in # the parameter which. This is inherent to the Krylov methods, and # should not be treated as a failure. If such a rare situation # occurs, the calculation is tried again (but at most a few times). One should 1st check whether one got correct eigenvalues, and try again if they are not the wanted ones. The current implementation does it backwards: it checks whether the eigenpair works, without 1st checking for eigenvalues. This commit corrects this programming error.
bb7423d
to
998400e
Compare
the failing check is due to the rebase over the current master, unrelated to the PR. |
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.
Okay, this should be good to go now - let's give it a try. Thanks @dimpase!
implemented in #14846 |
In scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py, eval_evec
one tests for correctness eigenpairs, in a loop,
which is meant to allow for an error (the
k
-tuple of eigenpairs found differs from what's asked bywhich
argument) in Krylov subspaces method. Cf. comments there:
One should 1st check whether one got correct eigenvalues, and try again
if they are not the wanted ones.
The current implementation does it backwards: it checks whether
the eigenpair works, without 1st checking for eigenvalues.
This commit corrects this programming error.
Reference issue
Requested by @rgommers in review of gh-14786
Additional information
#14786 (comment)