From 172a27fae4829933c4a8a7393aa6d0e71f9cc609 Mon Sep 17 00:00:00 2001 From: Jason Thai Date: Sat, 28 May 2022 00:36:43 -0700 Subject: TST: Added test for np.unique equal_nans kwarg --- numpy/lib/tests/test_arraysetops.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'numpy/lib/tests/test_arraysetops.py') diff --git a/numpy/lib/tests/test_arraysetops.py b/numpy/lib/tests/test_arraysetops.py index 13385cd24..f97fea310 100644 --- a/numpy/lib/tests/test_arraysetops.py +++ b/numpy/lib/tests/test_arraysetops.py @@ -765,3 +765,11 @@ class TestUnique: assert_array_equal(uniq[:, inv], data) msg = "Unique's return_counts=True failed with axis=1" assert_array_equal(cnt, np.array([2, 1, 1]), msg) + + def test_unique_nanequals(self): + # issue 20326 + a = np.array([1, 1, np.nan, np.nan, np.nan]) + unq = np.unique(a) + not_unq = np.unique(a, equal_nans = False) + assert_array_equal(unq, np.array([1, np.nan])) + assert_array_equal(not_unq, np.array([1, np.nan, np.nan, np.nan])) -- cgit v1.2.1