Re: [Numpy-discussion] MaskedArray and the min, max, sum, prod Methods
On Jan 4, 2008 10:01 AM, Pierre GM [EMAIL PROTECTED] wrote: On Thursday 03 January 2008 15:49:45 Alexander Michael wrote: Working with the new MaskedArray, I noticed the following differences with numpy.array behavior: masked_array([1, 2, 3], mask=True).min() 2147483647 That's a bug, the result should be maskedarray.masked. Samething for max, of course. masked_array([1, 2, 3], mask=True).prod() masked_array(data = --, mask = True, fill_value=1e+020) array([]).prod() 1.0 That's OK here, the result is maskedarray.masked. Ditto for sum Hmm. I liked the base ndarray behavior as it makes a lot of sense to me and provides an easy default that avoids needing to check the result between steps. Does MaskedArray do this to be compatible with the original ma, or is there a theoretically good reason for it that I am missing? Thanks! Alex ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] MaskedArray and the min, max, sum, prod Methods
On Friday 04 January 2008 10:27:32 Alexander Michael wrote: Hmm. I liked the base ndarray behavior as it makes a lot of sense to me and provides an easy default that avoids needing to check the result between steps. I must admit I have troubles conceptualizing the product of an empty array, so the ndarray behavior is a bit puzzling to me. Does MaskedArray do this to be compatible with the original ma, or is there a theoretically good reason for it that I am missing? Yes for the part. For the second, well, I think there's a difference between a maskedarray of a given size, where all values are masked, and an empty array. Any operation on a fully-masked array should result in maskedarray.masked. ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
[Numpy-discussion] MaskedArray and the min,max,sum,prod Methods
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 ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion