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

2007-10-25 Thread Pauli Virtanen
wBernhard Voigt <[EMAIL PROTECTED]> kirjoitti: > is nonzero the appropriate function to get the indexes of a boolean array? > > foo = numpy.random.random(1) > cut = foo > .5 > indexes = cut.nonzero()[0] I think writing indices = where(foo > 5)[0] might be more clear, although it does t

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

2007-10-25 Thread Bernhard Voigt
Dear list, is nonzero the appropriate function to get the indexes of a boolean array? foo = numpy.random.random(1) 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