[Numpy-discussion] Re: where

Robert Kern robert.kern at gmail.com
Thu Apr 13 09:54:05 CDT 2006

Ryan Krauss wrote:
> f and phase are each (4250,)
> I have something that is working but doesn't use where.  Can this be
> done easier using where:
> f1=f>19.5
> f2=f<38
> myf=f1&f2
> myp=phase>0
> myind=myf&myp
> correction=myind*-360
> newphase=phase+correction

phase[((f>19.5) & (f<38)) & (phase>0)] -= 360

> Basically, can where give me an output vector of the same size as f
> and phase where the output is either 1 or 0?

Why? The condition array that you would pass into where() is already such an array.

Robert Kern
robert.kern at gmail.com

"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