summaryrefslogtreecommitdiff
path: root/numpy/lib
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/lib')
-rw-r--r--numpy/lib/arraysetops.py3
-rw-r--r--numpy/lib/tests/test_arraysetops.py4
2 files changed, 5 insertions, 2 deletions
diff --git a/numpy/lib/arraysetops.py b/numpy/lib/arraysetops.py
index 5cd535703..691550579 100644
--- a/numpy/lib/arraysetops.py
+++ b/numpy/lib/arraysetops.py
@@ -163,8 +163,7 @@ def unique(ar, return_index=False, return_inverse=False):
ar = ar.flatten()
except AttributeError:
if not return_inverse and not return_index:
- items = sorted(set(ar))
- return np.asarray(items)
+ return np.sort(list(set(ar)))
else:
ar = np.asanyarray(ar).flatten()
diff --git a/numpy/lib/tests/test_arraysetops.py b/numpy/lib/tests/test_arraysetops.py
index 5934ca05a..e44ccd12b 100644
--- a/numpy/lib/tests/test_arraysetops.py
+++ b/numpy/lib/tests/test_arraysetops.py
@@ -65,6 +65,10 @@ class TestSetOps(TestCase):
bb = np.array(list(zip(b, b)), dt)
check_all(aa, bb, i1, i2, dt)
+ # test for ticket #2799
+ aa = [1.+0.j, 1- 1.j, 1]
+ assert_array_equal(np.unique(aa), [ 1.-1.j, 1.+0.j])
+
def test_intersect1d(self):
# unique inputs
a = np.array([5, 7, 1, 2])