-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
ENH: Add equals_nans kwarg to np.unique #21623
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: Matti Picus <matti.picus@gmail.com>
@asmeurer is this sufficient to bring np.unique(a, Bikeshedding on |
Co-authored-by: Matti Picus <matti.picus@gmail.com>
This got a green light in the developer meeeting, so LGTM. |
Actually, a little oops there. My/our argument was that we already have |
The array API specifies that nans are not equal. See https://data-apis.org/array-api/latest/API_specification/generated/signatures.set_functions.unique_all.html#signatures.set_functions.unique_all for instance. We would need to invert this flag in the array_api. The unique functions in the array API have new names so it wouldn't be backwards incompatible to change the default for them. |
@asmeurer NumPy has chosen in |
Yes, I believe it should be. We just need to add equal_nans=False to the wrappers in the array API. |
Addresses #20326
np.unique previously had it's functionality changed so NaN values would be treated as non-unique.
This PR puts the functionality into the kwarg equal_nans(default: True).