diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2019-11-04 17:32:10 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-04 17:32:10 -0700 |
commit | 4393e0c0cb1772d0f9691117d238d000b209decd (patch) | |
tree | 5dda9c9a885af59ecdcd4c3c947e69bd6bab48bf /numpy/lib/arraysetops.py | |
parent | 7b8513fff4c3673d8a967a1d72a73feab2072e8f (diff) | |
parent | 9aa8c4756d7282dd49a7093ce7a6725258106b9a (diff) | |
download | numpy-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.py | 8 |
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 |