[Numpy-discussion] [numpy] argmin in multidimensional arrays

Glen W. Mabey Glen.Mabey@swri....
Sat Mar 3 16:32:24 CST 2007


On Sat, Mar 03, 2007 at 03:09:35PM -0600, Robert Kern wrote:
> Glen W. Mabey wrote:
> > Does anyone else find this behavior counter-intuitive?  
> > 
> > It seems to me that one of the great design features of numpy is the
> > n-dim generality it provides, and argmin is one function in this breaks
> > down, IMHO.
> 
> Not at all. It consistently applies the simple rule: if the method operates over
> an axis, it takes an axis= keyword argument. The default for the axis= argument
> is None, which means that it operates over the flattened array. Other axes need
> to be specified explicitly.
> 
> See .sum(), .mean(), .var(), .repeat(), .min(), etc.

Okay, I see the reasoning.  I am glad that functions like sum, max, and
min return a single value, unless axis is specified.

However, it seems to me that the arg* functions are inherently
different.  After all, it is an index that is sought instead of a value, 
and when this result cannot be directly applied to the original array, 
then at first glance it appears to be ... less than intuitive.

Thanks for your reply.

Glen



More information about the Numpy-discussion mailing list