summaryrefslogtreecommitdiff
path: root/numpy/lib/arraysetops.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2021-02-10 09:31:12 -0700
committerGitHub <noreply@github.com>2021-02-10 09:31:12 -0700
commit00f6ddb9881a9587c915b3db00fa6e99bd025bf3 (patch)
treebb86378575a256e3c694462dc4687df3b2097a7e /numpy/lib/arraysetops.py
parent1900913b4c226e4cb49ab466671ed56bccb3f700 (diff)
parent8fbd472e562237dd56ce251e266e2090d6c5003b (diff)
downloadnumpy-00f6ddb9881a9587c915b3db00fa6e99bd025bf3.tar.gz
Merge pull request #18369 from AngelGris/bugfix-for-in1d-with-tuples
BUG: np.in1d bug on the object array (issue 17923)
Diffstat (limited to 'numpy/lib/arraysetops.py')
-rw-r--r--numpy/lib/arraysetops.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/numpy/lib/arraysetops.py b/numpy/lib/arraysetops.py
index 6c6c1ff80..eb5c488e4 100644
--- a/numpy/lib/arraysetops.py
+++ b/numpy/lib/arraysetops.py
@@ -565,6 +565,10 @@ def in1d(ar1, ar2, assume_unique=False, invert=False):
ar1 = np.asarray(ar1).ravel()
ar2 = np.asarray(ar2).ravel()
+ # Ensure that iteration through object arrays yields size-1 arrays
+ if ar2.dtype == object:
+ ar2 = ar2.reshape(-1, 1)
+
# Check if one of the arrays may contain arbitrary objects
contains_object = ar1.dtype.hasobject or ar2.dtype.hasobject