[Numpy-discussion] MaskedArray and the min,max,sum,prod Methods

Alexander Michael lxander.m@gmail....
Thu Jan 3 14:49:45 CST 2008


Working with the new MaskedArray, I noticed the following differences
with numpy.array behavior:

>>> masked_array([1, 2, 3], mask=True).min()
2147483647
>>> array([]).min()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: zero-size array to ufunc.reduce without identity

>>> masked_array([1, 2, 3], mask=True).max()
-2147483648
>>> array([]).max()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: zero-size array to ufunc.reduce without identity

>>> masked_array([1, 2, 3], mask=True).prod()
masked_array(data = --,
      mask = True,
      fill_value=1e+020)
>>> array([]).prod()
1.0

>>> masked_array([1, 2, 3], mask=True).sum()
masked_array(data = --,
      mask = True,
      fill_value=1e+020)
>>> numpy.array([]).sum()
0.0

Are these corner cases intentionally different?

Thanks,
Alex


More information about the Numpy-discussion mailing list