-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: handle NaNs in FloatingArray.equals #44390
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: handle NaNs in FloatingArray.equals #44390
Conversation
jbrockmendel
commented
Nov 11, 2021
•
edited
Loading
edited
- closes BUG: FloatingArray.equals should consider NaNs in same location as equal #44382
- tests added / passed
- Ensure all linting tests pass, see here for how to run them
- whatsnew entry
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! One small comment
data = np.array([1.0, np.nan, 3.0], dtype=np.float64) | ||
|
||
left = FloatingArray(data, mask) | ||
assert left.equals(left) |
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.
Could you do something like left2 = FloatingArray(data.copy(), mask.copy())
to create the other array to test equality with? I would just avoid the special case of "identical" objects (in case we might add a fastpath for that in the future)
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.
updated; is this what you had in mind?
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.
That's fine!
Can you add a small whatsnew note?
do we have reference docs for these anywhere? (i don't remember), if so can you add otherwise lgtm |
actually would be great to tests Series equals with FloatDtype (does it dispatch to this?) |
Yes. The relevant one for users is https://pandas.pydata.org/docs/dev/reference/api/pandas.Series.equals.html#, and the ExtensionArray version is also listed: https://pandas.pydata.org/docs/dev/reference/api/pandas.api.extensions.ExtensionArray.equals.html
Yes, it does dispatch, and that's already tested. |
where is the series test explicitly added here? |
It is not added here because we already have a general extension test ( |
sure but do we have an example that was failing with Float dtypes that check nans - we couldn't have as it would have failed - so need this case |
We have a lot of specific tests in the |
i think this wasnt ready, had failures on older numpys |
It seems the |
shimmed a fix for this into #44428 |
Can you quickly put it in its own PR? That seems easier to merge it quickly, while the other PR still needs to be reviewed? |