[Numpy-discussion] Re: where

Ryan Krauss ryanlists at gmail.com
Thu Apr 13 10:12:06 EDT 2006


Sorry, I can't explain myself.

I read the docstring and it didn't make sense before.  Now it seems
clear enough.

Some how I got it in my head that I needed to be passing f and phase
so that condition could use them.

It turns out that this:
 myvect=where((f>19.5) & (f<38) &
(phase>0),ones(shape(phase)),zeros(shape(phase)))

does exactly what I want.

Ryan

On 4/13/06, Robert Kern <robert.kern at gmail.com> wrote:
> Ryan Krauss wrote:
> > Does where return a mask?
> >
> > If I do
> > myvect=where((f > 19.5) & (phase > 0),f,phase)
> > myvect is the same length as f and phase and there is some
> > modification of the values where the condition is met, but what that
> > modification is is unclear to me.
> >
> > If I do
> > myind=where((f > 19.5) & (phase > 0))
> > I seem to get the indices of the points where both conditions are met.
> >
> > I am using version 0.9.5.2043.  I see those kinds of errors about
> > truth testing an array often, but not in this case.
>
> Have you read the docstring?
>
> In [33]: where?
> Type:           builtin_function_or_method
> Base Class:     <type 'builtin_function_or_method'>
> String Form:    <built-in function where>
> Namespace:      Interactive
> Docstring:
>     where(condition, | x, y) is shaped like condition and has elements of x and
> y where condition is respectively true or false.  If x or y are not given, then
> it is equivalent to nonzero(condition).
>
> --
> 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
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by xPML, a groundbreaking scripting language
> that extends applications into web and mobile media. Attend the live webcast
> and join the prime developer group breaking into this new coding territory!
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/numpy-discussion
>




More information about the NumPy-Discussion mailing list