summaryrefslogtreecommitdiff
path: root/numpy/ma/extras.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/ma/extras.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/ma/extras.py')
-rw-r--r--numpy/ma/extras.py10
1 files changed, 4 insertions, 6 deletions
diff --git a/numpy/ma/extras.py b/numpy/ma/extras.py
index 51064e831..64a9844cf 100644
--- a/numpy/ma/extras.py
+++ b/numpy/ma/extras.py
@@ -1278,14 +1278,12 @@ def setdiff1d(ar1, ar2, assume_unique=False):
fill_value = 999999)
"""
- if not assume_unique:
+ if assume_unique:
+ ar1 = ma.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 ma.asarray(ar1)[aux == 0]
+ return ar1[in1d(ar1, ar2, assume_unique=True, invert=True)]
#####--------------------------------------------------------------------------