-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
MAINT: Make assert_array_compare more generic. #11756
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
numpy/testing/_private/utils.py
Outdated
@@ -704,7 +706,7 @@ def func_assert_same_pos(x, y, func=isnan, hasval='nan'): | |||
# compared usefully, and for which .all() yields masked. | |||
x_id = func(x) | |||
y_id = func(y) | |||
if (x_id == y_id).all() != True: | |||
if npany(x_id != y_id): |
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.
Would it be overkill to mock up an ndarray
subclass for which this succeeds but the previous version fails for a test of the test?
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 thought about it, but didn't want to tie us into that behavior. Could add a comment.
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.
Since we are removing the != True
reference in the comment on line 704, shouldn't we update the comment?
689d0a3
to
06eb262
Compare
@tylerjereddy Added a comment and made the changes more conservative. |
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 found a typo but everything is green and seems sensible beyond that
numpy/testing/_private/utils.py
Outdated
# Both the != True comparison here and the cast to bool_ at the end are | ||
# done to deal with `masked`, which cannot be compared usefully, and | ||
# for which np.all yields masked. The use of the function np.all is | ||
# for backcompatility with ndarray subclasses that changed the return |
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.
typo -> compatibility
Use np.all instead of the *.all method to be a bit more robust against bad subclasses of ndarray that may change the behavior of the method. Closes numpy#11743.
06eb262
to
78efe63
Compare
Use np.any instead of method to be a bit more robust against bad
subclassing of ndarray.
Closes #11743.