diff options
author | Warren Weckesser <warren.weckesser@gmail.com> | 2020-03-12 19:53:13 -0400 |
---|---|---|
committer | Warren Weckesser <warren.weckesser@gmail.com> | 2020-03-15 11:35:39 -0400 |
commit | d18156b00d4215d869d71f1d4c7d66037bd50b4b (patch) | |
tree | 11f7955d2bdb480efecc63cadb4b56c744597597 /numpy/lib/tests/test_arraysetops.py | |
parent | 353bf737fb84fe285b430e6496aa7537f56a674f (diff) | |
download | numpy-d18156b00d4215d869d71f1d4c7d66037bd50b4b.tar.gz |
BUG: lib: Handle axes with length 0 in np.unique.
Tweak a few lines so that arrays with an axis with length 0
don't break the np.unique code.
Closes gh-15559.
Diffstat (limited to 'numpy/lib/tests/test_arraysetops.py')
-rw-r--r-- | numpy/lib/tests/test_arraysetops.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_arraysetops.py b/numpy/lib/tests/test_arraysetops.py index f7d91a26a..babc4e439 100644 --- a/numpy/lib/tests/test_arraysetops.py +++ b/numpy/lib/tests/test_arraysetops.py @@ -563,6 +563,12 @@ class TestUnique: result = np.array([[-0.0, 0.0]]) assert_array_equal(unique(data, axis=0), result, msg) + @pytest.mark.parametrize("axis", [0, -1]) + def test_unique_1d_with_axis(self, axis): + x = np.array([4, 3, 2, 3, 2, 1, 2, 2]) + uniq = unique(x, axis=axis) + assert_array_equal(uniq, [1, 2, 3, 4]) + def test_unique_axis_zeros(self): # issue 15559 single_zero = np.empty(shape=(2, 0), dtype=np.int8) |