[Numpy-discussion] bug in oldnumeric.ma
Anne Archibald
peridot.faceted@gmail....
Wed May 7 13:47:18 CDT 2008
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
More information about the Numpy-discussion
mailing list