in1d needs an asarray call? #2755

Closed
jseabold opened this Issue Nov 21, 2012 · 2 comments

Projects

None yet

2 participants

@jseabold
Contributor

Consider this

[~/]
[1]: test = np.array([0,1,2,5,0])

[~/]
[2]: states = [0, 2]

[~/]
[3]: np.in1d(test, states)
[3]: array([ True, False,  True, False,  True], dtype=bool)

[~/]
[4]: np.in1d(test, test)
[4]: array([ True,  True,  True,  True,  True], dtype=bool)

[~/]
[5]: np.in1d(states, states)
[5]: array([False, False], dtype=bool)

[~/]
[6]: np.in1d(np.array(states), states)
[6]: array([ True,  True], dtype=bool)
@seberg
Member
seberg commented Nov 21, 2012

This is a regression introduced in 6441c2a due to the new special case lacking the asarray call. Maybe it should better be fixed for 1.7? Also a .ravel() should probably be added since at least if assume_unique was not given, this was done in the unique call.

@seberg seberg added a commit to seberg/numpy that referenced this issue Dec 8, 2012
@seberg seberg 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"
6d3950c
@certik certik added a commit to certik/numpy that referenced this issue Dec 26, 2012
@seberg @certik seberg + certik 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"
42e5b80
@seberg
Member
seberg commented Jan 3, 2013

Fixed in 1.7 and master.

@seberg seberg closed this Jan 3, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment