From f28615092d6cd7f849dd09d0dc57471af7def143 Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Tue, 13 Feb 2018 21:47:51 -0700 Subject: 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. --- numpy/lib/tests/test_arraysetops.py | 11 +++++++++++ 1 file changed, 11 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 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], -- cgit v1.2.1 From 7bf0564f87511d9e7b6287b3eec0857d0d7742df Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Wed, 4 Apr 2018 10:33:07 -0600 Subject: MAINT: Remove all uses of run_module_suite. That function is nose specific and has not worked since `__init__` files were added to the tests directories. --- numpy/lib/tests/test_arraysetops.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (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 8286834a4..76c36c53e 100644 --- a/numpy/lib/tests/test_arraysetops.py +++ b/numpy/lib/tests/test_arraysetops.py @@ -6,9 +6,7 @@ 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, - ) +from numpy.testing import assert_array_equal, assert_equal, assert_raises from numpy.lib.arraysetops import ( ediff1d, intersect1d, setxor1d, union1d, setdiff1d, unique, in1d, isin ) @@ -504,7 +502,3 @@ class TestUnique(object): 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) - - -if __name__ == "__main__": - run_module_suite() -- cgit v1.2.1