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
Add atol
argument to function is_O3
#14371
Conversation
Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.
|
Thanks! I need this needs a change log. 😸 |
Thanks @cmarmo! This looks very good. It would be good to add @mhvk, |
Should I introduce |
My tendency would be not to propagate it, since all it really provides in It would be nice, though, for the default
(factor 5 to reproduce ~1e-15 for float64) |
I think that's a good change! And this will help with |
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.
@@ -136,14 +136,18 @@ def angle_axis(matrix): | |||
return Angle(angle, u.radian), -axis / r | |||
|
|||
|
|||
def is_O3(matrix): | |||
def is_O3(matrix, atol=1e-15): |
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.
def is_O3(matrix, atol=1e-15): | |
def is_O3(matrix, atol=None): |
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.
@nstarman, I changed a bit your suggestion, as one of the tests uses an int64 matrix and finfo
was giving me the numpy error
ValueError: data type <class 'numpy.int64'> not inexact
Once fixed it, the value of atol
for integers was None
and that was giving me another numpy error
TypeError: unsupported operand type(s) for +: 'NoneType' and 'float'
I hope the current version reproduces the expected behavior...
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.
Thanks @cmarmo. This is getting close. The new additions aren't completely covered by the test suite, which should be an easy fix.
if isinstance(matrix.dtype, np.floating): | ||
atol = np.finfo(matrix.dtype).eps * 5 |
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.
There's a small mistake here. The dtype can't be checked this way because the dtype
is a class, not an instance. The way to check the dtype is with issubdtype. This should fix the test issue.
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.
Thanks! :)
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.
May I ask you why this fixed the test? Also , is this line still useful?
assert tuple(is_rotation(n1, atol=None)) == (True, True) # (show the broadcasting) |
Sorry I'm a bit thick...
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.
It's just that float64
is not an instance of a subclass of floating
.
|
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.
Thanks @cmarmo for the PR and fast turnaround. Last request, please squash down the number of commits to 1 to 3. Thanks!
Also let's get the approval of one of the coordinates maintainers!
Co-authored-by: Nathaniel Starkman <nstarman@users.noreply.github.com>
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.
Looks all good! Thanks, @cmarmo!
Description
This pull request is to address the addition of the
atol
argument to the functionis_O3
.Related test is added.
Fixes #13694
Thank you for considering it.