[SciPy-dev] Shoud ma.filled change dtype?

Sasha ndarray at mac.com
Sun Jan 8 00:12:59 CST 2006


In the current version of numpy.core.ma, masked values can be filled
by arbitrary value.  If the fill value cannot be converted to an
appropriate type, an object array is returned:

>>> from numpy.core.ma import *
>>> x = array([1],mask=[1])
>>> x.filled(1j)
array([1j], dtype=object)

Note that in the example the resulting array is an object array with
complex numbers in it.  This creature is very similar in behavior to a
complex array, but is slower and takes many times more memory. If real
x was filled with a complex number by mistake, this mistake is likely
to go unnoticed.

I don't think this feature is useful and I've just spent a day chasing
a bug related to this feature. If one really wants to create an object
array from a masked array of numbers, it is easy to convert the array
explicitely. (With the current implementation this will also be a
faster option.)

There is probably some history behind this feature.  If so, can
someone educate me?

Thanks.

-- sasha




More information about the Scipy-dev mailing list