|
From: Darren D. <dd...@co...> - 2006-02-09 12:23:20
|
On Thursday 09 February 2006 7:03 am, Darren Dale wrote:
> I have a question about upcasting related to this example:
>
> a with elements less than 0.5 zeroed out:
> Matlab: a .* (a>0.5)
> NumPy: where(a<0.5, 0, a)
>
> I think numpy should be able to do a*a>0.5 as well, but instead one must
> do: a*(a>0.5).astype('i')
>
> Is it desireable to upcast bools in this case? I think so, one could always
> recover the current behavior by doing:
> (a*(a>0.5)).astype('?')
oops:
I should have been doing a*(a>0.5), the order of operations is important. My
mistake.
|