[Numpy-discussion] array += masked_array gives a normal array, not masked array
Tony Yu
tsyu80@gmail....
Sun Jun 1 10:22:05 CDT 2008
Ok, so you guys shot down my last attempt at finding a bug :). Here's
another attempt.
array + masked_array
outputs a masked array
array += masked_array
outputs an array.
I'm actually not sure if this is a bug (works the same for both the
old and new masked arrays), but I thought this was unexpected.
*However*, if the right side were an old masked array, the masked
values would not be added to the output array. With the new masked
arrays, the data from the masked array is added regardless of whether
the value is masked (example, below).
-Tony
Example:
=======
In [1]: import numpy
In [2]: normal = numpy.array([1, 1])
In [3]: masked = numpy.ma.array([1, 1], mask=[True, False])
In [4]: new_masked = normal + masked
In [5]: new_masked
Out[5]:
masked_array(data = [-- 2],
mask = [ True False],
fill_value=999999)
In [6]: normal += masked
In [7]: normal
Out[7]: array([2, 2])
# If used old masked arrays in the above, the final output would be:
array([1, 2])
More information about the Numpy-discussion
mailing list