summaryrefslogtreecommitdiff
path: root/numpy/lib/arraysetops.py
diff options
context:
space:
mode:
authorSebastian Berg <sebastian@sipsolutions.net>2012-12-08 14:07:46 +0100
committerSebastian Berg <sebastian@sipsolutions.net>2012-12-08 14:09:42 +0100
commit6d3950c8ac3ad6088a473acc7d68ba405c14267c (patch)
tree623f7940d7806a78fff484811dc8f80052a8c168 /numpy/lib/arraysetops.py
parent7b75899f586ee476affbf89572d0105996725d94 (diff)
downloadnumpy-6d3950c8ac3ad6088a473acc7d68ba405c14267c.tar.gz
BUG: Fix regression for in1d with non-array input
There was a regression introduced by the speed improvement in commit 6441c2a. This fixes it, and generally ravels the arrays for np.in1d. However it can be argued that at least the first array should not be ravelled in the future. Fixes "Issue gh-2755"
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 20a0e7151..ae14970e2 100644
--- a/numpy/lib/arraysetops.py
+++ b/numpy/lib/arraysetops.py
@@ -324,6 +324,10 @@ def in1d(ar1, ar2, assume_unique=False):
array([0, 2, 0])
"""
+ # Ravel both arrays, behavior for the first array could be different
+ ar1 = np.asarray(ar1).ravel()
+ ar2 = np.asarray(ar2).ravel()
+
# This code is significantly faster when the condition is satisfied.
if len(ar2) < 10 * len(ar1) ** 0.145:
mask = np.zeros(len(ar1), dtype=np.bool)