[Numpy-discussion] where construct

lorenzo bolla lbolla@gmail....
Sun Dec 16 13:22:13 CST 2007


use '+' instead of 'or' for bool arrays.

In [8]: numpy.where((a<1) + (b<3), b, c)
Out[8]: array([4, 2, 2, 1])

hth,
L.

On Dec 16, 2007 8:10 PM, Ross Harder <brussel13@yahoo.com> wrote:

>
> What's the correct way to do something like this?
>
> a=array( (0,1,1,0) )
> b=array( (4,3,2,1) )
> c=array( (1,2,3,4) )
>
> where( (a<1 or b<3), b,c)
>
> Python throws a ValueError
> I would expect to get an array that looks like
> [4,2,2,1] I think
>
>
> Thanks,
> Ross
>
>
>
>  ____________________________________________________________________________________
> Never miss a thing.  Make Yahoo your home page.
> http://www.yahoo.com/r/hs
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20071216/e5b89e48/attachment.html 


More information about the Numpy-discussion mailing list