[Numpy-discussion] bug in oldnumeric.ma

Pierre GM pgmdevlist@gmail....
Wed May 7 14:12:18 CDT 2008


All,
Yes, there is a problem with ma.power: masking negative data should be 
restricted to the case of an exponent between -1. and 1. only, don't you 
think ?

On Wednesday 07 May 2008 18:47:18 Anne Archibald wrote:
> 2008/5/7 Eric Firing <efiring@hawaii.edu>:
> > Charles Doutriaux wrote:
> >  > The following code works with numpy.ma but not numpy.oldnumeric.ma,
> >
> >  No, this is a bug in numpy.ma also; power is broken:
>
> While it's tempting to just call power() and mask out any NaNs that
> result, that's going to be a problem if people have their environments
> set to raise exceptions on the production of NaNs. Is it an adequate
> criterion to check (a<0) & (round(b)==b)? We have to be careful:
>
> In [16]: np.array([-1.0])**(2.0**128)
> Warning: invalid value encountered in power
> Out[16]: array([                  nan])
>
> 2.0**128 cannot be distinguished from nearby non-integral values, so
> this is reasonable behaviour (and a weird corner case), but
>
> In [23]: np.round(2.0**128) == 2.0**128
> Out[23]: True
>
> Anne
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion




More information about the Numpy-discussion mailing list