From 14fc78319e1b61cb2806be7059f78d03a02bc7f7 Mon Sep 17 00:00:00 2001 From: "Bradley M. Froehle" Date: Tue, 4 Dec 2012 10:23:11 -0800 Subject: BUG: gh-2785, np.unique: TypeError: requested sort not available for type Revert "BUG: ticket #2063, make unique return consistent index." This reverts commit 74b9f5eef8fac643bf9012dbb2ac6b4b19f46892. Conflicts: numpy/core/tests/test_regression.py This commit introduced a regression in `np.unique` for certain data types: >>> A = np.array([[1, 2], [1, 3], [1, 2]], dtype='i') >>> B, I, J = np.unique(A.view([('', A.dtype)]*A.shape[1]), True, True) Traceback (most recent call last): File ".../numpy/lib/arraysetops.py", line 178, in unique perm = ar.argsort(kind='mergesort') TypeError: requested sort not available for type --- numpy/lib/arraysetops.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'numpy/lib/arraysetops.py') diff --git a/numpy/lib/arraysetops.py b/numpy/lib/arraysetops.py index 47e94bc4d..721039238 100644 --- a/numpy/lib/arraysetops.py +++ b/numpy/lib/arraysetops.py @@ -112,8 +112,8 @@ def unique(ar, return_index=False, return_inverse=False): unique : ndarray The sorted unique values. unique_indices : ndarray, optional - The indices of the first occurrences of the unique values in the - (flattened) original array. Only provided if `return_index` is True. + The indices of the unique values in the (flattened) original array. + Only provided if `return_index` is True. unique_inverse : ndarray, optional The indices to reconstruct the (flattened) original array from the unique array. Only provided if `return_inverse` is True. @@ -174,10 +174,7 @@ def unique(ar, return_index=False, return_inverse=False): return ar if return_inverse or return_index: - if return_index: - perm = ar.argsort(kind='mergesort') - else: - perm = ar.argsort() + perm = ar.argsort() aux = ar[perm] flag = np.concatenate(([True], aux[1:] != aux[:-1])) if return_inverse: -- cgit v1.2.1