[SciPy-User] faster nonzero indices
Felix Schlesinger
schlesin at cshl.edu
Wed Oct 21 00:02:53 EDT 2009
Is there a faster way to do:
foo = scipy.nonzero(bar > 1)[0]
where bar is a 1d ndarray of type 'int32'
i.e. to get all indices of an array for which a condition is true.
Since in this case the arrays are quite large and the condition is only true for
few items creating a long boolean array and then passing over it again to find
non zero entries seems inefficient.
Felix
More information about the SciPy-User
mailing list