-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
TST: add dtype dependent default rtol to xp_assert_close #20625
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
Conversation
Co-authored-by: Matt Haberland <mhaberla@calpoly.edu>
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.
I'm happy if Ralf is happy
As examples of how this can clean things up: Numerically, the rtol for |
I have only browsed this PR briefly, just wanted to give a 👍🏼 to the general idea of dtype-dependent tolerances. |
We just discussed this on a call about the NASA grant, and scikit-learn is doing something similar. They manually set the values to 1e-4 for float32 and 1e-7 for everything else. That's close enough to what we have here, so I'm going to go ahead and merge this so this no longer holds up other PRs. @j-bowhay, would you make a post on the forum to alert developers to the change, and invite them to submit a PR with a different specific choice of defaults if there are strong objections to these numerical values? |
Different array libraries have different default floating dtypes and as such the default
rtol=1e-7
ofxp_assert_close
can be too stringent when using the default type. This leaves two options:dtype
of the input data eg.xp.asarray(..., dtype=xp.float64)
rtol
The first is potentially as undesirable as it is reasonable to expect the user to be using the default type most of the time. The second is potentially undesirable as it makes the test unnecessarily less stringent for some libraries.
As for the choice of value:
Originally posted by @mdhaber in #20595 (comment)