summaryrefslogtreecommitdiff
path: root/numpy/lib/arraysetops.py
diff options
context:
space:
mode:
authorChristian Brodbeck <christianmbrodbeck@gmail.com>2015-05-06 10:49:41 -0400
committerChristian Brodbeck <christianmbrodbeck@gmail.com>2015-05-07 09:03:16 -0400
commitc05019eda16477f4be99f47755362c07e1acb5b8 (patch)
treeeab1de86ac3332d64f9179750b726b460584d8a7 /numpy/lib/arraysetops.py
parenteecb2e3c07f29c0ac991d364a846a2f8293a432a (diff)
downloadnumpy-c05019eda16477f4be99f47755362c07e1acb5b8.tar.gz
BUG: setdiff1d return dtype
Fixes #5846 (If called with an empty array as first argument, the returned array had dtype bool instead of the dtype of the input array)
Diffstat (limited to 'numpy/lib/arraysetops.py')
-rw-r--r--numpy/lib/arraysetops.py10
1 files changed, 4 insertions, 6 deletions
diff --git a/numpy/lib/arraysetops.py b/numpy/lib/arraysetops.py
index 7776d7e76..3dd97aecf 100644
--- a/numpy/lib/arraysetops.py
+++ b/numpy/lib/arraysetops.py
@@ -470,11 +470,9 @@ def setdiff1d(ar1, ar2, assume_unique=False):
array([1, 2])
"""
- if not assume_unique:
+ if assume_unique:
+ ar1 = np.asarray(ar1).ravel()
+ else:
ar1 = unique(ar1)
ar2 = unique(ar2)
- aux = in1d(ar1, ar2, assume_unique=True)
- if aux.size == 0:
- return aux
- else:
- return np.asarray(ar1)[aux == 0]
+ return ar1[in1d(ar1, ar2, assume_unique=True, invert=True)]