summaryrefslogtreecommitdiff
path: root/numpy/lib/arraysetops.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2019-11-04 17:32:10 -0700
committerGitHub <noreply@github.com>2019-11-04 17:32:10 -0700
commit4393e0c0cb1772d0f9691117d238d000b209decd (patch)
tree5dda9c9a885af59ecdcd4c3c947e69bd6bab48bf /numpy/lib/arraysetops.py
parent7b8513fff4c3673d8a967a1d72a73feab2072e8f (diff)
parent9aa8c4756d7282dd49a7093ce7a6725258106b9a (diff)
downloadnumpy-4393e0c0cb1772d0f9691117d238d000b209decd.tar.gz
Merge pull request #14800 from mattip/reorder-obj-comparison-loop
ENH: change object-array comparisons to prefer OO->O unfuncs
Diffstat (limited to 'numpy/lib/arraysetops.py')
-rw-r--r--numpy/lib/arraysetops.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/numpy/lib/arraysetops.py b/numpy/lib/arraysetops.py
index 2309f7e42..cf45e181b 100644
--- a/numpy/lib/arraysetops.py
+++ b/numpy/lib/arraysetops.py
@@ -562,11 +562,15 @@ def in1d(ar1, ar2, assume_unique=False, invert=False):
if invert:
mask = np.ones(len(ar1), dtype=bool)
for a in ar2:
- mask &= (ar1 != a)
+ # convert object arrays to bool
+ # cannot use np.not_equal until 'S' and 'U' have loops
+ mask &= (ar1 != a).astype(bool)
else:
mask = np.zeros(len(ar1), dtype=bool)
for a in ar2:
- mask |= (ar1 == a)
+ # convert object arrays to bool
+ # cannot use np.equal until 'S' and 'U' have loops
+ mask |= (ar1 == a).astype(bool)
return mask
# Otherwise use sorting