[SciPy-dev] maskedarray.maximum inconsistent with numpy.ma.maximum

Pierre GM pgmdevlist at gmail.com
Mon May 7 16:48:28 EDT 2007


On Monday 07 May 2007 14:54:38 David Huard wrote:
> maskedarray.maximum(2darray) returns a 1d array,
> whereas
> numpy.ma.maximum returns a scalar.

David, thx for the info.
The explanation is that numpy.core.ma.maximum computes the max of the 
compressed array (turned into 1D), while maskedarray.maximum calls 
numpy.core.umath.maximum.reduce on the 2D array. 
And numpy.core.umath.maximum.reduce on a 2D array returns a 1D array (the 
default axis is 0). Is this behavior wanted ? An axis=None is not recognized 
as a valid argument for numpy.core.umath.maximum, unfortunately...

> This difference breaks matplotlib contour function when numpy.ma is
> replaced by maskedarray.
That's unfortunate indeed. A quick fix is to force a 'ravel' on 'target' 
in '_extrema_operation.reduce', just after kargs={}.

Before commiting the fix, I'd like to know whether 
numpy.core.umath.maximum.reduce should accept a None value for the axis...



More information about the SciPy-Dev mailing list