From 6d3950c8ac3ad6088a473acc7d68ba405c14267c Mon Sep 17 00:00:00 2001 From: Sebastian Berg Date: Sat, 8 Dec 2012 14:07:46 +0100 Subject: 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" --- numpy/lib/arraysetops.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'numpy/lib/arraysetops.py') 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) -- cgit v1.2.1