[Numpy-discussion] Maskedarray implementations
Pierre GM
pgmdevlist at gmail.com
Fri Aug 24 20:27:41 EDT 2007
All,
As you might be aware, there are currently two concurrent implementations of
masked arrays in numpy:
* numpy.ma is the official implementation, but it is unclear whether it is
still actively maintained.
* maskedarray is the alternative I've been developing initially for my own
purpose from numpy.ma. It is available in the scipy svn sandbox, but is
already fully functional
The main difference between numpy.ma and maskedarray is that the objects
created by numpy.ma are NOT ndarrays, while maskedarray.MaskedArray is a full
subclass of ndarrays. For example:
>>>import numpy, maskedarray
>>>x = numpy.ma.array([1,2], mask=[0,1])
>>>isinstance(x, numpy.ndarray)
False
>>>numpy.asanyarray(x)
array([1,2])
Note that we just lost the mask...
>>>x = maskedarray.array([1,2], mask=[0,1])
>>>isinstance(x, numpy.ndarray)
True
>>>numpy.asanyarray(x)
masked_array(data = [1 --],
mask = [False True],
fill_value=999999)
Note that the mask is conserved.
Having the masked array be a subclass of ndarray makes masked arrays easier to
mix with other ndarray types and to subclass. An example of application is
the TimeSeries package, where the main TimeSeries class is a subclass of
maskedarray.MaskedArray.
* Does anyone see any *disadvantages* to this aspect of maskedarray relative
to numpy.ma?
* What would be the requisites to move maskedarray out of the sandbox ? We
hope to be able in the short term to either replace or at least merge the two
implementations, once a couple of issues are addressed (but we can talk about
that later...)
Thanks a lot in advance for your feedback
Pierre
More information about the NumPy-Discussion
mailing list