[Numpy-discussion] strange seterr persistence between sessions
John Hunter
jdh2358@gmail....
Mon Jul 28 14:56:18 CDT 2008
On Mon, Jul 28, 2008 at 2:35 PM, Robert Kern <robert.kern@gmail.com> wrote:
> Both, if the behavior exhibits itself without the npy file. If it only
> exhibits itself with an npy involved, then we have some more
> information about where the problem might be.
OK, I'll see what I can come up with. In the mean time, as I was
trying to strip out the npy component and put the data directly into
the file, I find it strange that I am getting a floating point error
on this operation
import numpy as np
np.seterr("raise")
import numpy.ma as ma
x = 1.50375883
m = ma.MaskedArray([x])
sinc_alpha_ma = ma.sin(m) / m
---------------------------------------------------------------------------
FloatingPointError Traceback (most recent call last)
/home/jdhunter/<ipython console> in <module>()
/home/jdhunter/dev/lib64/python2.5/site-packages/numpy/ma/core.pyc in
__div__(self, other)
1885 def __div__(self, other):
1886 "Divide other into self, and return a new masked array."
-> 1887 return divide(self, other)
1888 #
1889 def __truediv__(self, other):
/home/jdhunter/dev/lib64/python2.5/site-packages/numpy/ma/core.pyc in
__call__(self, a, b)
636 d1 = getdata(a)
637 d2 = get_data(b)
--> 638 t = narray(self.domain(d1, d2), copy=False)
639 if t.any(None):
640 mb = mask_or(mb, t)
/home/jdhunter/dev/lib64/python2.5/site-packages/numpy/ma/core.pyc in
__call__(self, a, b)
411 if self.tolerance is None:
412 self.tolerance = np.finfo(float).tiny
--> 413 return umath.absolute(a) * self.tolerance >= umath.absolute(b)
414 #............................
415 class _DomainGreater:
FloatingPointError: underflow encountered in multiply
I am no floating point expert, but I don't see why a numerator of
0.99775383 and a denominator of 1.50375883 should be triggering an
underflow error. It looks more like a bug in the ma core logic since
umath.absolute(a) * self.tolerance is more or less guaranteed to fail
if np.seterr("raise") is set
JDH
More information about the Numpy-discussion
mailing list