summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
Diffstat (limited to 'numpy')
-rw-r--r--numpy/lib/arraysetops.py4
-rw-r--r--numpy/lib/tests/test_arraysetops.py5
2 files changed, 7 insertions, 2 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)
diff --git a/numpy/lib/tests/test_arraysetops.py b/numpy/lib/tests/test_arraysetops.py
index b0d2ca7c3..f7e7bfdca 100644
--- a/numpy/lib/tests/test_arraysetops.py
+++ b/numpy/lib/tests/test_arraysetops.py
@@ -124,8 +124,9 @@ class TestSetOps(TestCase):
# we use two different sizes for the b array here to test the
# two different paths in in1d().
for mult in (1, 10):
- a = np.array([5, 7, 1, 2])
- b = np.array([2, 4, 3, 1, 5] * mult)
+ # One check without np.array, to make sure lists are handled correct
+ a = [5, 7, 1, 2]
+ b = [2, 4, 3, 1, 5] * mult
ec = np.array([True, False, True, True])
c = in1d(a, b, assume_unique=True)
assert_array_equal(c, ec)