[Numpy-discussion] bug with with fill_values in masked arrays?
Matt Knox
mattknox_ca@hotmail....
Fri Mar 21 14:08:29 CDT 2008
Chris,
The behaviour you are seeing is intentional. Pierre is correct in asserting that
it is not a bug. Now, you may disagree with the behaviour, but the behaviour is
by design and is not a bug. Perhaps you are misunderstanding how to use masked
arrays, which is understandable because the documentation is currently sparse.
Take a look at the following example (using the latest svn version of numpy and
matplotlib 0.91.2).
######################################################
import numpy as np
from numpy import ma
import pylab
data = [1., 2., 3., np.nan, 5., 6.]
mask = [0, 0, 0, 1, 0, 0]
marr = ma.array(data, mask=mask)
marr.set_fill_value(55)
print marr.data
print marr.mask
print marr[0] is ma.masked # False
print marr[3] # ma.masked constant
print marr.mask[3] # True
print marr.data[3] # is a nan value with svn numpy, not sure about 1.0.4
print marr[3] is ma.masked # True
print marr.data[3] is ma.masked # False
filled_arr = marr.filled()
print filled_arr # nan value is replaced with fill value of 55
pylab.plot(marr) # masked value shows up as a gap in the plot
pylab.show()
######################################################
All of the behaviour outlined above is (as far as I know) by design, and makes
sense to me at least. If you disagree with some of the above behaviour, then I'm
sure people would be happy to hear your opinion, but it is incorrect to flatly
call this a bug.
- Matt
More information about the Numpy-discussion
mailing list