[Numpy-discussion] Keywords in wrapped functions

Travis E. Oliphant oliphant@enthought....
Tue Jun 24 13:48:04 CDT 2008

Pierre GM wrote:
> All,
> Sorry to bumpt the post, accept my apologies for my rudeness, but I'm 
> curious...
> So, let me rephrase my question:
> Many numpy functions (min, max, sum...) based on ndarray methods have a 
> construction of the style
> #-----------------------------------------------
> def amin(a, axis=None, out=None):
>     try:
>         amin = a.min
>     except AttributeError:
>         return _wrapit(a, 'min', axis, out)
>     return amin(axis, out)
> #-----------------------------------------------
> I'm wondering why the initial keywords arguments are transformed into 
> positional arguments in the return. In the previous example, I would expect a 
> line like
> return amin(axis=axis, out=out)
> [Actually, I would even prefer a 
> return amin(axis=axis, out=out, **other_optional_parameters), which would 
> permit to add some extra parameters such as a "fill_value", when dealing with 
> masked arrays ?]
> Is this for efficiency purposes ?
The keyword arguments to the methods were added later and so positional 
argument were initially necessary.  I don't think they are now, but I 
have not verified that.


More information about the Numpy-discussion mailing list