[Numpy-discussion] difficulty with numpy.where
Keith Goodman
kwgoodman@gmail....
Thu Oct 1 12:00:00 CDT 2009
On Thu, Oct 1, 2009 at 9:55 AM, Dr. Phillip M. Feldman
<pfeldman@verizon.net> wrote:
>
> I've defined the following one-line function that uses numpy.where:
>
> def sin_half_period(x): return where(0.0 <= x <= pi, sin(x), 0.0)
>
> When I try to use this function, I get an error message:
>
> In [4]: z=linspace(0,2*pi,9)
> In [5]: sin_half_period(z)
> ---------------------------------------------------------------------------
> ValueError Traceback (most recent call last)
>
> The truth value of an array with more than one element is ambiguous. Use
> a.any
> () or a.all()
>
> Any suggestions will be appreciated.
Take a look at this thread:
http://www.nabble.com/Compound-conditional-indexing-td25686443.html
More information about the NumPy-Discussion
mailing list