[Numpy-discussion] how to select indices from boolean array

Bernhard Voigt bernhard.voigt@gmail....
Thu Oct 25 07:25:30 CDT 2007

Dear list,

is nonzero the appropriate function to get the indexes of a boolean array?

foo = numpy.random.random(10000)
cut = foo > .5
indexes = cut.nonzero()[0]

Another question: Why is the the type returned by nonzero a tuple and not an
ndarray of the same shape as the input (or self if used on an object)?

Thanks! Bernhard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20071025/b2482810/attachment.html 

More information about the Numpy-discussion mailing list