diff options
author | Jaime <jaime.frio@gmail.com> | 2015-05-07 06:40:26 -0700 |
---|---|---|
committer | Jaime <jaime.frio@gmail.com> | 2015-05-07 06:40:26 -0700 |
commit | 21932fbfc217b4a8bc547fa267ea5597d7dcb59b (patch) | |
tree | 2dcd7fc81806b6864c34d57930348dc9da6121a1 /numpy/lib/arraysetops.py | |
parent | 6bb8c0d46739d6d9bb23cb48670519d7eb620d4d (diff) | |
parent | c05019eda16477f4be99f47755362c07e1acb5b8 (diff) | |
download | numpy-21932fbfc217b4a8bc547fa267ea5597d7dcb59b.tar.gz |
Merge pull request #5847 from christianbrodbeck/fix/setdiff1d
BUG: setdiff1d return type
Fixes 5846
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)] |