Discussion:
[Numpy-discussion] fromnumeric.py internal calls
G Young
2016-02-24 08:40:15 UTC
Permalink
Hello all,

I have PR #7325 <https://github.com/numpy/numpy/pull/7325/files> up that
changes the internal calls for functions in *fromnumeric.py* from
positional arguments to keyword arguments. I made this change for two
reasons:

1) It is consistent with the external function signature
2)

The inconsistency caused a breakage in *pandas* in its own implementation
of *searchsorted* in which the *sorter* argument is not really used but is
accepted so as to make it easier for *numpy* users who may be used to the
*searchsorted* signature in *numpy*.

The standard in *pandas* is to "swallow" those unused arguments into a
*kwargs* argument so that we don't have to document an argument that we
don't really use. However, that turned out not to be possible when
*searchsorted* is called from the *numpy* library.

Does anyone have any objections to the changes I made?

Thanks!

Greg
Stephan Hoyer
2016-02-29 07:44:30 UTC
Permalink
I think this is an improvement, but I do wonder if there are libraries out
there that use *args instead of **kwargs to handle these extra arguments.
Perhaps it's worth testing this change against third party array libraries
that implement their own array like classes? Off the top of my head, maybe
scipy, pandas, dask, astropy, pint, xarray?
Post by G Young
Hello all,
I have PR #7325 <https://github.com/numpy/numpy/pull/7325/files> up that
changes the internal calls for functions in *fromnumeric.py* from
positional arguments to keyword arguments. I made this change for two
1) It is consistent with the external function signature
2)
The inconsistency caused a breakage in *pandas* in its own implementation
of *searchsorted* in which the *sorter* argument is not really used but
is accepted so as to make it easier for *numpy* users who may be used to
the *searchsorted* signature in *numpy*.
The standard in *pandas* is to "swallow" those unused arguments into a
*kwargs* argument so that we don't have to document an argument that we
don't really use. However, that turned out not to be possible when
*searchsorted* is called from the *numpy* library.
Does anyone have any objections to the changes I made?
Thanks!
Greg
_______________________________________________
NumPy-Discussion mailing list
https://mail.scipy.org/mailman/listinfo/numpy-discussion
G Young
2016-02-29 08:07:28 UTC
Permalink
Well I know pandas uses **kwargs (that was the motivation for this PR), but
I can certainly have a look at those other ones. I am not too familiar
with all of the third party libraries that implement their own array-like
classes, so if there any others that come to mind, let me know! Also,
could you also add that as a comment to the PR as well? Thanks!
Post by Stephan Hoyer
I think this is an improvement, but I do wonder if there are libraries out
there that use *args instead of **kwargs to handle these extra arguments.
Perhaps it's worth testing this change against third party array libraries
that implement their own array like classes? Off the top of my head, maybe
scipy, pandas, dask, astropy, pint, xarray?
Post by G Young
Hello all,
I have PR #7325 <https://github.com/numpy/numpy/pull/7325/files> up that
changes the internal calls for functions in *fromnumeric.py* from
positional arguments to keyword arguments. I made this change for two
1) It is consistent with the external function signature
2)
The inconsistency caused a breakage in *pandas* in its own
implementation of *searchsorted* in which the *sorter* argument is not
really used but is accepted so as to make it easier for *numpy* users
who may be used to the *searchsorted* signature in *numpy*.
The standard in *pandas* is to "swallow" those unused arguments into a
*kwargs* argument so that we don't have to document an argument that we
don't really use. However, that turned out not to be possible when
*searchsorted* is called from the *numpy* library.
Does anyone have any objections to the changes I made?
Thanks!
Greg
_______________________________________________
NumPy-Discussion mailing list
https://mail.scipy.org/mailman/listinfo/numpy-discussion
_______________________________________________
NumPy-Discussion mailing list
https://mail.scipy.org/mailman/listinfo/numpy-discussion
Loading...