From 12f83eb7337b840e3cd9026779b99b1af8033bf3 Mon Sep 17 00:00:00 2001 From: Aaron Meurer Date: Fri, 3 Jun 2022 15:21:19 -0600 Subject: Fix the array API unique_*() functions to not compare nans as equal The spec requires this, but it is only now possible to implement with the new equal_nan flag in np.unique(). --- numpy/array_api/_set_functions.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'numpy/array_api/_set_functions.py') diff --git a/numpy/array_api/_set_functions.py b/numpy/array_api/_set_functions.py index db9370f84..0b4132cf8 100644 --- a/numpy/array_api/_set_functions.py +++ b/numpy/array_api/_set_functions.py @@ -46,6 +46,7 @@ def unique_all(x: Array, /) -> UniqueAllResult: return_counts=True, return_index=True, return_inverse=True, + equal_nan=False, ) # np.unique() flattens inverse indices, but they need to share x's shape # See https://github.com/numpy/numpy/issues/20638 @@ -64,6 +65,7 @@ def unique_counts(x: Array, /) -> UniqueCountsResult: return_counts=True, return_index=False, return_inverse=False, + equal_nan=False, ) return UniqueCountsResult(*[Array._new(i) for i in res]) @@ -80,6 +82,7 @@ def unique_inverse(x: Array, /) -> UniqueInverseResult: return_counts=False, return_index=False, return_inverse=True, + equal_nan=False, ) # np.unique() flattens inverse indices, but they need to share x's shape # See https://github.com/numpy/numpy/issues/20638 @@ -98,5 +101,6 @@ def unique_values(x: Array, /) -> Array: return_counts=False, return_index=False, return_inverse=False, + equal_nan=False, ) return Array._new(res) -- cgit v1.2.1