In a low-level function that is called many times, I need to do the equivalent of python\'s list.index, but with a numpy array. The function needs to return when it finds the f
The closest thing I could find to what you're asking for is nonzero. It may sound odd, but the documentation makes it look like it might have the desired result.
http://www.scipy.org/Numpy_Example_List_With_Doc#nonzero
Specifically this part:
a.nonzero()
Return the indices of the elements that are non-zero.
Refer to
numpy.nonzero
for full documentation.See Also
numpy.nonzero : equivalent function
>>> from numpy import *
>>> y = array([1,3,5,7])
>>> indices = (y >= 5).nonzero()
>>> y[indices]
array([5, 7])
>>> nonzero(y) # function also exists
(array([0, 1, 2, 3]),)
Where (http://www.scipy.org/Numpy_Example_List_With_Doc#where) may also be of interest to you.