summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_arraysetops.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2018-02-13 21:47:51 -0700
committerCharles Harris <charlesr.harris@gmail.com>2018-02-14 12:56:44 -0700
commitf28615092d6cd7f849dd09d0dc57471af7def143 (patch)
tree684ead9b2ba4e4c7e2eb40b82b675ef6f9563d5b /numpy/lib/tests/test_arraysetops.py
parentdfad6d530866300f4e964486be2d963204636daa (diff)
downloadnumpy-f28615092d6cd7f849dd09d0dc57471af7def143.tar.gz
BUG: Revert sort optimization in np.unique.
The optimization was to sort integer subarrays by treating them as strings of unsigned bytes. That worked fine for finding the unique subarrays, but the sort order of the results could be unexpected. Closes #10495.
Diffstat (limited to 'numpy/lib/tests/test_arraysetops.py')
-rw-r--r--numpy/lib/tests/test_arraysetops.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_arraysetops.py b/numpy/lib/tests/test_arraysetops.py
index 17415d8fe..8286834a4 100644
--- a/numpy/lib/tests/test_arraysetops.py
+++ b/numpy/lib/tests/test_arraysetops.py
@@ -4,6 +4,8 @@
from __future__ import division, absolute_import, print_function
import numpy as np
+import sys
+
from numpy.testing import (
run_module_suite, assert_array_equal, assert_equal, assert_raises,
)
@@ -453,6 +455,15 @@ class TestUnique(object):
assert_array_equal(v.data, v2.data, msg)
assert_array_equal(v.mask, v2.mask, msg)
+ def test_unique_sort_order_with_axis(self):
+ # These tests fail if sorting along axis is done by treating subarrays
+ # as unsigned byte strings. See gh-10495.
+ fmt = "sort order incorrect for integer type '%s'"
+ for dt in 'bhilq':
+ a = np.array([[-1],[0]], dt)
+ b = np.unique(a, axis=0)
+ assert_array_equal(a, b, fmt % dt)
+
def _run_axis_tests(self, dtype):
data = np.array([[0, 1, 0, 0],
[1, 0, 0, 0],