[Numpy-discussion] where construct
Sun Dec 16 13:38:56 CST 2007
"or" is logical or. You want "|" which is bitwise/elementwise or. Also,
watch the order of operations -- | has higher precedence than <.
Thus, you want
where( (a<1) | (b<3), b,c)
Ross Harder 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
> Never miss a thing. Make Yahoo your home page.
> Numpy-discussion mailing list
More information about the Numpy-discussion