[Numpy-discussion] numpy.ma.arg{min,max}

Christopher Barker Chris.Barker at noaa.gov
Fri Apr 10 18:16:06 EDT 2009


Adam Oliner wrote:
> The documentation for numpy.ma.argmin says:
> "Returns array of indices of the maximum values along the given axis."
> 
> Aside from probably meaning to say the 'minimum' values,

that's a typo...


> it also doesn't seem to return an array:

it does if you use a higher rank array, and specify an axis:

 >>> a
array([[ 0.643502  ,  0.83867769,  0.97762954,  0.49686553],
        [ 0.37798796,  0.69300396,  0.06683333,  0.3457077 ],
        [ 0.51357262,  0.29095034,  0.42811108,  0.72644421],
        [ 0.5977396 ,  0.64992292,  0.53068753,  0.46386281]])

 >>> np.argmin(a, 0)
array([1, 2, 1, 1])

 >>> np.argmin(a, 1)

array([3, 2, 1, 3])


argmin(a, axis=None)
     Return array of indices to the minimum values along the given axis.

     Parameters
     ----------
     a : {array_like}
         Array to look in.
     axis : {None, integer}
         If None, the index is into the flattened array, otherwise along
         the specified axis




-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov



More information about the NumPy-Discussion mailing list