[Numpy-discussion] Getting indices from numpy array with condition

Robert Kern robert.kern at gmail.com
Wed Nov 19 02:38:54 EST 2008


On Wed, Nov 19, 2008 at 01:31, David Warde-Farley <dwf at cs.toronto.edu> wrote:
> On 18-Nov-08, at 3:06 PM, Robert Kern wrote:
>
>> I like to discourage this use of where(). For some reason, back in
>> Numeric's days, where() got stuck with two functionalities. nonzero()
>> is the preferred function for this functionality. IMO, where(cond,
>> if_true, if_false) should be the only use of where().
>
> Hmm. nonzero() seems semantically awkward to be calling on a boolean
> array, n'est pas?

Why? In Python and numpy, False==0 and True==1.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
  -- Umberto Eco



More information about the NumPy-Discussion mailing list