summaryrefslogtreecommitdiff
path: root/numpy/lib/arraysetops.py
diff options
context:
space:
mode:
authorjaimefrio <jaime.frio@gmail.com>2015-01-25 09:20:55 -0800
committerjaimefrio <jaime.frio@gmail.com>2015-01-25 09:26:31 -0800
commit704dcc00cd1bfb89280dd42fc061592004811da6 (patch)
tree8b3c68127ceb89647a835d0215d71580cc6c848c /numpy/lib/arraysetops.py
parent7ce93ba046b1ff2fddd1f24090b21c01a7d6c25e (diff)
downloadnumpy-704dcc00cd1bfb89280dd42fc061592004811da6.tar.gz
ENH: speed-up in1d replacing sorting with fancy indexing
Diffstat (limited to 'numpy/lib/arraysetops.py')
-rw-r--r--numpy/lib/arraysetops.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/numpy/lib/arraysetops.py b/numpy/lib/arraysetops.py
index d3b6119f4..cb24eb24e 100644
--- a/numpy/lib/arraysetops.py
+++ b/numpy/lib/arraysetops.py
@@ -392,12 +392,13 @@ def in1d(ar1, ar2, assume_unique=False, invert=False):
else:
bool_ar = (sar[1:] == sar[:-1])
flag = np.concatenate((bool_ar, [invert]))
- indx = order.argsort(kind='mergesort')[:len(ar1)]
+ ret = np.empty(ar.shape, dtype=bool)
+ ret[order] = flag
if assume_unique:
- return flag[indx]
+ return ret[:len(ar1)]
else:
- return flag[indx][rev_idx]
+ return ret[rev_idx]
def union1d(ar1, ar2):
"""