I get different behavior from in1ddepending on which machine I run my script on. On my desktop (numpy version 1.6.2) I'm trying
x = np.array('a b c d e f g h i j'.split())
np.in1d(x, set(['f', 'e', 'r']))
array([False, False, False, False, True, True, False, False, False, False], dtype=bool)
as I expected. On my laptop (version 1.8.1), the result is all FalseI don't want.
Playing a bit, I found that
np.in1d(x, ['f', 'e', 'r'])
works in both versions, but I don’t understand why the function does not work properly when transferring a set.
source
share