diff options
author | Christian Brodbeck <christianmbrodbeck@gmail.com> | 2015-05-06 10:49:41 -0400 |
---|---|---|
committer | Christian Brodbeck <christianmbrodbeck@gmail.com> | 2015-05-07 09:03:16 -0400 |
commit | c05019eda16477f4be99f47755362c07e1acb5b8 (patch) | |
tree | eab1de86ac3332d64f9179750b726b460584d8a7 /numpy/lib/arraysetops.py | |
parent | eecb2e3c07f29c0ac991d364a846a2f8293a432a (diff) | |
download | numpy-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.py | 10 |
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)] |