summaryrefslogtreecommitdiff
path: root/numpy/lib/arraysetops.py
diff options
context:
space:
mode:
authorThomas J. Fan <thomasjpfan@gmail.com>2021-06-29 14:19:02 -0400
committerGitHub <noreply@github.com>2021-06-29 13:19:02 -0500
commit6ff787b93d46cca6d31c370cfd9543ed573a98fc (patch)
tree058097f5e52f06b6b62597b339642cabcc18fde9 /numpy/lib/arraysetops.py
parent2f0ed6acea1308c89e6c814b1317d96362370703 (diff)
downloadnumpy-6ff787b93d46cca6d31c370cfd9543ed573a98fc.tar.gz
BUG: Do not raise deprecation warning for all nans in unique (#19301)
This PR adjusts np.unique for the edge cases where all values are nan. Fixes gh-19300
Diffstat (limited to 'numpy/lib/arraysetops.py')
-rw-r--r--numpy/lib/arraysetops.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/numpy/lib/arraysetops.py b/numpy/lib/arraysetops.py
index 7600e17be..bd56b6975 100644
--- a/numpy/lib/arraysetops.py
+++ b/numpy/lib/arraysetops.py
@@ -339,7 +339,9 @@ def _unique1d(ar, return_index=False, return_inverse=False,
aux_firstnan = np.searchsorted(np.isnan(aux), True, side='left')
else:
aux_firstnan = np.searchsorted(aux, aux[-1], side='left')
- mask[1:aux_firstnan] = (aux[1:aux_firstnan] != aux[:aux_firstnan - 1])
+ if aux_firstnan > 0:
+ mask[1:aux_firstnan] = (
+ aux[1:aux_firstnan] != aux[:aux_firstnan - 1])
mask[aux_firstnan] = True
mask[aux_firstnan + 1:] = False
else: