diff options
author | jaimefrio <jaime.frio@gmail.com> | 2014-06-06 16:57:14 -0700 |
---|---|---|
committer | jaimefrio <jaime.frio@gmail.com> | 2014-06-06 16:57:39 -0700 |
commit | 44529602509f7af4d103ce968248eafbd51af5be (patch) | |
tree | 47a333ddab725ab57d9c3e449efc14b0eb3e3270 /numpy/lib/tests/test_arraysetops.py | |
parent | 4c854c2633894387988b43306ff72333cb00613a (diff) | |
download | numpy-44529602509f7af4d103ce968248eafbd51af5be.tar.gz |
BUG: Correct behavior for lists of tuples in unique, closes #4785
np.unique produces wrong results when passed a list of tuples and
no keyword arguments, as it fails to recognize it as a multidim
array, but handles it as a 1D array of objects. The only way around
this seems to be to completely eliminate the fast path for non-array
inputs using `set`.
Diffstat (limited to 'numpy/lib/tests/test_arraysetops.py')
-rw-r--r-- | numpy/lib/tests/test_arraysetops.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_arraysetops.py b/numpy/lib/tests/test_arraysetops.py index 41d77c07f..271943abc 100644 --- a/numpy/lib/tests/test_arraysetops.py +++ b/numpy/lib/tests/test_arraysetops.py @@ -97,6 +97,16 @@ class TestSetOps(TestCase): aa = [1.+0.j, 1- 1.j, 1] assert_array_equal(np.unique(aa), [ 1.-1.j, 1.+0.j]) + # test for ticket #4785 + a = [(1, 2), (1, 2), (2, 3)] + unq = [1, 2, 3] + inv = [0, 1, 0, 1, 1, 2] + a1 = unique(a) + assert_array_equal(a1, unq) + a2, a2_inv = unique(a, return_inverse=True) + assert_array_equal(a2, unq) + assert_array_equal(a2_inv, inv) + def test_intersect1d(self): # unique inputs a = np.array([5, 7, 1, 2]) |