ryanlists at gmail.com
Thu Apr 13 09:44:01 CDT 2006
f and phase are each (4250,)
I have something that is working but doesn't use where. Can this be
done easier using where:
Basically, can where give me an output vector of the same size as f
and phase where the output is either 1 or 0?
On 4/13/06, Travis Oliphant <oliphant at ee.byu.edu> wrote:
> Ryan Krauss wrote:
> >Does where return a mask?
> Only in the second use case...
> >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.
> The behavior of
> where(condition, for_true, for_false)
> is to return an array of the same shape as condition with elements of
> for_true where condition is true and
> for_false where condition is false.
> Thus myvect will contain elements of f where the condition is met and
> elements of phase otherwise.
> >If I do
> >myind=where((f > 19.5) & (phase > 0))
> >I seem to get the indices of the points where both conditions are met.
> Yes. That is correct. It is a different use-case... Note, however,
> that in the current SVN version of NumPy, this use-case will always
> return a tuple of indices (use the nonzero function instead for behavior
> that will stay constant). For your 1-d example (I'm guessing it's 1-d)
> where will return a length-1 tuple.
> >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.
> That is strange. What are the sizes of f and phase?
More information about the Numpy-discussion