summaryrefslogtreecommitdiff
path: root/numpy/core
diff options
context:
space:
mode:
authorBryan Van de Ven <bryan@laptop.local>2012-03-19 10:08:33 -0500
committerCharles Harris <charlesr.harris@gmail.com>2012-03-30 08:27:54 -0600
commitdbf235169ed3386b359caaa9217f5280bf1d6749 (patch)
tree09ca74c170813e131b66660ae28ddb66c3d8ba27 /numpy/core
parent960a86be3539f67ea5200d6fe22ae0e82324af30 (diff)
downloadnumpy-dbf235169ed3386b359caaa9217f5280bf1d6749.tar.gz
BUG: ticket #2063, make unique return consistent index.
Make unique use mergesort when return_index is true. This quarantees that the returned indices are of the first occurrence of the unique elements and makes the behavior better defined and consistent.
Diffstat (limited to 'numpy/core')
-rw-r--r--numpy/core/tests/test_regression.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/numpy/core/tests/test_regression.py b/numpy/core/tests/test_regression.py
index fc530987e..090498a63 100644
--- a/numpy/core/tests/test_regression.py
+++ b/numpy/core/tests/test_regression.py
@@ -1673,6 +1673,14 @@ class TestRegression(TestCase):
a = np.array([u'abcd'])
assert_equal(a.dtype.itemsize, 16)
+ def test_unique_stable(self):
+ # Ticket #2063 must always choose stable sort for argsort to
+ # get consistent results
+ v=np.array([0,0,0,0,0,1,1,1,1,1,1,2,2,2,2,2,2]*4)
+ w=np.array([0,0,0,0,0,1,1,1,1,1,1,2,2,2,2])
+ resv = np.unique(v,return_index=True)
+ resw = np.unique(w,return_index=True)
+ assert_equal(resv, resw)
if __name__ == "__main__":
run_module_suite()