[Numpy-discussion] Matrix vs array in ma.minimum
Pierre GM
pgmdevlist at gmail.com
Fri Jan 15 04:10:51 EST 2010
On Jan 14, 2010, at 11:06 PM, David Cournapeau wrote:
> On Fri, Jan 15, 2010 at 11:59 AM, Pierre GM <pgmdevlist at gmail.com> wrote:
>> 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.
>
> Damn, I thought I coul
>>
>>> 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 ?
>
> Here is a self-contained example reproducing the matplotlib pb:
>
OK, thx a lot. I'll work on it as soon as I can.
More information about the NumPy-Discussion
mailing list