diff options
author | Thomas J. Fan <thomasjpfan@gmail.com> | 2021-06-29 14:19:02 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-29 13:19:02 -0500 |
commit | 6ff787b93d46cca6d31c370cfd9543ed573a98fc (patch) | |
tree | 058097f5e52f06b6b62597b339642cabcc18fde9 /numpy/lib/tests | |
parent | 2f0ed6acea1308c89e6c814b1317d96362370703 (diff) | |
download | numpy-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/tests')
-rw-r--r-- | numpy/lib/tests/test_arraysetops.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_arraysetops.py b/numpy/lib/tests/test_arraysetops.py index d62da9efb..13385cd24 100644 --- a/numpy/lib/tests/test_arraysetops.py +++ b/numpy/lib/tests/test_arraysetops.py @@ -610,6 +610,17 @@ class TestUnique: assert_equal(np.unique(a, return_inverse=True), (ua, ua_inv)) assert_equal(np.unique(a, return_counts=True), (ua, ua_cnt)) + # test for gh-19300 + all_nans = [np.nan] * 4 + ua = [np.nan] + ua_idx = [0] + ua_inv = [0, 0, 0, 0] + ua_cnt = [4] + assert_equal(np.unique(all_nans), ua) + assert_equal(np.unique(all_nans, return_index=True), (ua, ua_idx)) + assert_equal(np.unique(all_nans, return_inverse=True), (ua, ua_inv)) + assert_equal(np.unique(all_nans, return_counts=True), (ua, ua_cnt)) + def test_unique_axis_errors(self): assert_raises(TypeError, self._run_axis_tests, object) assert_raises(TypeError, self._run_axis_tests, |