Hi, Suppose I have a flat array, and I want to know the indices corresponding to values contained in a list of arbitrary lenght.
Intuitively I would have done: a = np.array([1,2,3,4]) np.nonzero(a in (0,2,4)) However the "in" operator doesn't work element-wise, instead it compares the whole array with each member of the list. I have found that this does the trick: b = (0,2,4) reduce(np.logical_or, [a == i for i in b]) then pass the result to np.nonzero to get the indices, but, is there a numpy function that can handle this situation? Cheers. Ernest _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion