[Numpy-discussion] MaskedArray and the min,max,sum,prod Methods
Alexander Michael
lxander.m at gmail.com
Thu Jan 3 15:49:45 EST 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