[Numpy-discussion] f.p. powers and masked arrays
Michael Fitzgerald
fitz at astron.berkeley.edu
Wed Jun 21 23:39:51 CDT 2006
Hello all,
I'm encountering some (relatively new?) behavior with masked arrays that
strikes me as bizarre. Raising zero to a floating-point value is triggering
a mask to be set, even though the result should be well-defined. When using
fixed-point integers for powers, everything works as expected. I'm seeing
this with both numarray and numpy. Take the case of 0**1, illustrated below:
>>> import numarray as n1
>>> import numarray.ma as n1ma
>>> n1.array(0.)**1
array(0.0)
>>> n1.array(0.)**1.
array(0.0)
>>> n1ma.array(0.)**1
array(0.0)
>>> n1ma.array(0.)**1.
array(data =
[1.0000000200408773e+20],
mask =
1,
fill_value=[ 1.00000002e+20])
>>> import numpy as n2
>>> import numpy.core.ma as n2ma
>>> n2.array(0.)**1
array(0.0)
>>> n2.array(0.)**1.
array(0.0)
>>> n2ma.array(0.)**1
array(0.0)
>>> n2ma.array(0.)**1.
array(data =
1e+20,
mask =
True,
fill_value=1e+20)
I've been using python v2.3.5 & v.2.4.3, numarray v1.5.1, and numpy v0.9.8,
and tested this on an x86 Debian box and a PPC OSX box. It may be the case
that this issue has manifested in the past several months, as it's causing a
new problem with some of my older code. Any thoughts?
Thanks in advance,
Mike
More information about the Numpy-discussion
mailing list