2008/5/9 Eric Firing <[EMAIL PROTECTED]>: > Stefan, (and Jarrod and Pierre) > > (Context for anyone new to the thread: the subject is slightly > misleading, because the bug is/was present in both oldnumeric.ma and > numpy.ma; the discussion of fix pertains to the latter only.) > > Regarding your objections to r5137: good point. I wondered about that. > I think the function should look like this (although it might be > possible to speed up the implementation for the most common case): [...] > md = make_mask((fb != fb.astype(int)) & (fa < 0), shrink=True)
Unfortunately this isn't quite the right condition: In [18]: x = 2.**35; numpy.array([-1.])**x; numpy.array(x).astype(int)==x Out[18]: array([ 1.]) Out[18]: False Switching to int64 seems to help: In [27]: x = 2.**62; numpy.array([-1.])**x; numpy.array(x).astype(numpy.int64)==x Out[27]: array([ 1.]) Out[27]: True This seems to work, but may be platform-dependent: 2**62+1 cannot be represented as an IEEE float, so whether pow() successfully deals with it may be different for machines that don't work with 80-bit floating-point internally. A suspenders-and-belt approach would check for NaNs and add them to the mask, but this still doesn't cover the case where the user has numpy set to raise exceptions any time NaNs are generated. Anne _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion