[Numpy-discussion] MA bug or feature?

Michael Sorich michael.sorich at gmail.com
Wed Jun 21 04:46:19 EDT 2006

When transposing a masked array of dtype '<f8' I noticed that an
ndarray of dtype '|O4' was returned. I found this a little strange as
the masked array did not contain any masked values. Upon closer
examination (see script below) it seems that if the mask is a boolean
array with all false values and the fill_value is a string this will
occur. However if the fill_value is a number or the mask is simply
False, the dtype stays as '<f8'. I was going to submit this as a bug
but wanted to check that this was not a deliberate feature.

I am using the numpy version that comes with a recent version of
python enthought edition.

import numpy
print numpy.version.version

ma1 = numpy.ma.array(((1.,2,3),(4,5,6)), mask=((0,0,0),(0,0,0)))
print ma1.filled('NA').dtype
print ma1.filled(-999).dtype

ma2 = numpy.ma.array(((1.,2,3),(4,5,6)), mask=False)
print ma2.filled('NA').dtype
print ma2.filled(-999).dtype

More information about the NumPy-Discussion mailing list