-
-
Notifications
You must be signed in to change notification settings - Fork 11.3k
BUG: Fix np.unique with axis=0 and 1D input not collapsing NaNs with equal_nan=True #29336 #29372
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: Fix np.unique with axis=0 and 1D input not collapsing NaNs with equal_nan=True #29336 #29372
Conversation
corrected white space
Review comment implementation
63104ca
to
7f04ede
Compare
Hi @ngoldbaum , |
Haven't looked at this, but one note/question is how it ties back to: #27345 (and maybe there is even something relevant for this there). |
@seberg , |
@seberg are we going to merge this PR ? ,as it is a Quick fix for 1st case(For 1D arrays, np.nan values are not treated as equal even when equal_nan=True.) |
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 let's give this a shot (I'll just apply the doc fixes).
@seberg Thanks for the feedback on the doc changes — let’s continue the discussion in a second PR as you suggested! |
Nothing to do, thanks for the PR and nice tests! Just waiting for CI to merge. |
It's passing now! I'd hit the button but I don't quite have time to read through this whole thread again... |
What was the Issue
Issue link :- #29336
Bug Description:- The equal_nan parameter in numpy.unique does not work correctly in some cases. Specifically:
For 1D arrays, np.nan values are not treated as equal even when equal_nan=True.
For 2D arrays with axis=0, the issue is similar — np.nan values are not treated as equal.
What This PR Fixes
This pull request fixes the issue for 1D arrays only.
Fixed: np.unique(..., equal_nan=True) now treats NaNs as equal in 1D arrays.
Notes
This PR does not address the 2D case (e.g., np.unique(array, axis=0, equal_nan=True)) described in the same issue.In coming days i will investigate and provide fix for this case as well