[Numpy-discussion] Matrix vs array in ma.minimum
Thu Jan 14 19:52:02 CST 2010
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. The problem appears when using pylab.imshow on
matrices, because matplotlib (and not matlab :) ) uses masked arrays
when normalizing the values.
More information about the NumPy-Discussion