ENH: Add equals_nans kwarg to np.unique#21623
Conversation
Co-authored-by: Matti Picus <[email protected]>
|
@asmeurer is this sufficient to bring np.unique(a, Bikeshedding on |
Co-authored-by: Matti Picus <[email protected]>
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).