[Numpy-discussion] Matrix vs array in ma.minimum
Thu Jan 14 20:59:53 CST 2010
On Jan 14, 2010, at 8:52 PM, David Cournapeau wrote:
> Pierre GM wrote:
>> Er, no.
>> np.ma.minimum(a, b) returns the lowest value of a and b element-wsie, or the the lowest element of a is b is None. The behavior is inherited from the very first implementation of maskedarray in numeric. This itself is unexpected, since np.minimum requires at least 2 input arguments.
>> As you observed, the current function breaks down w/ np.matrix objects when only one argument is given (and when the axis is None): we call umath.minimum.reduce on the ravelled matirx, which returns the ravelled matrix. One would expect a scalar, so yes, this behavior is also unexpected.
>> Now, which way should we go ? Keep np.ma.minimum as it is (fixing the bug so that a scalar is returned if the function is called with only 1 argument and an axis None) ? Adapt it to match np.minimum ?
> I am not a user of Masked Array, so I don't know what is the most
> desirable behavior.
I'm not a regular user of np.minimum.
> The problem appears when using pylab.imshow on
> matrices, because matplotlib (and not matlab :) ) uses masked arrays
> when normalizing the values.
David, you mind pointing me to the relevan part of the code and/or give me an example ?
In any case, I'd appreciate more feedback on the behavior of np.ma.minimum.
More information about the NumPy-Discussion