summaryrefslogtreecommitdiff
path: root/numpy/lib/arraysetops.py
diff options
context:
space:
mode:
authorwufangjie <wufangjie1223@126.com>2017-07-27 11:21:05 +0800
committerGitHub <noreply@github.com>2017-07-27 11:21:05 +0800
commitcba15d5ec3472ac167bdfe06f32dc07d6bbabd4d (patch)
treeeee9d7b46190eab166dcae2b788f9407a5701273 /numpy/lib/arraysetops.py
parentf3e4a44c43dd5b1adc9f003071badca7f294eceb (diff)
downloadnumpy-cba15d5ec3472ac167bdfe06f32dc07d6bbabd4d.tar.gz
make `setxor1d' a bit clear and speed up
We need to find the index which is not the same with the left and right, I think np.logical_and's meaning is more clear and I test this got a speed up
Diffstat (limited to 'numpy/lib/arraysetops.py')
-rw-r--r--numpy/lib/arraysetops.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/numpy/lib/arraysetops.py b/numpy/lib/arraysetops.py
index 9b0a1193f..a454b8725 100644
--- a/numpy/lib/arraysetops.py
+++ b/numpy/lib/arraysetops.py
@@ -378,8 +378,9 @@ def setxor1d(ar1, ar2, assume_unique=False):
# flag = ediff1d( aux, to_end = 1, to_begin = 1 ) == 0
flag = np.concatenate(([True], aux[1:] != aux[:-1], [True]))
# flag2 = ediff1d( flag ) == 0
- flag2 = flag[1:] == flag[:-1]
- return aux[flag2]
+# flag2 = flag[1:] == flag[:-1]
+# return aux[flag2]
+ return aux[np.logical_and(flag[1:], flag[:-1])]
def in1d(ar1, ar2, assume_unique=False, invert=False):