Proposal to accept NEP-18, __array_function__ protocol

classic Classic list List threaded Threaded
62 messages Options
1234
Reply | Threaded
Open this post in threaded view
|

Re: Proposal to accept NEP-18, __array_function__ protocol

Joris Van den Bossche
Hi all,

I have small question for clarification regarding some reducing numpy functions like np.sum, np.mean, etc, i.e. functions that now work on other array-like objects by checking if they have 'sum', 'mean', etc method and if so, "dispatch" to the method.
Those functions are several times mentioned as examples in the text of the NEP, so although the NEP does not list the functions that will use the __array_function__ protocol explicitly, I assume that those functions will probably be in that list. But I wanted to check if that assumption is correct.

Is it the intent that the functions that now dispatch to object methods will be updated to use the protocol instead? (probably keeping to method-dispatch as second try for backwards compatibility)

Not something urgent, but I was just wondering that when reading the NEP, as this is something that would be useful for pandas (where we now need to do some gymnastics to deal with arguments passed by numpy to those methods that we don't support).

Joris



_______________________________________________
NumPy-Discussion mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/numpy-discussion
Reply | Threaded
Open this post in threaded view
|

Re: Proposal to accept NEP-18, __array_function__ protocol

Stephan Hoyer-2
On Wed, Sep 26, 2018 at 9:19 AM Joris Van den Bossche <[hidden email]> wrote:
Hi all,

I have small question for clarification regarding some reducing numpy functions like np.sum, np.mean, etc, i.e. functions that now work on other array-like objects by checking if they have 'sum', 'mean', etc method and if so, "dispatch" to the method.
Those functions are several times mentioned as examples in the text of the NEP, so although the NEP does not list the functions that will use the __array_function__ protocol explicitly, I assume that those functions will probably be in that list. But I wanted to check if that assumption is correct.

Is it the intent that the functions that now dispatch to object methods will be updated to use the protocol instead? (probably keeping to method-dispatch as second try for backwards compatibility)

Hi Joris,

Yes, this is my exact intent. Eventually, we might remove/deprecate automatically calling methods with the same name (due to how error prone this is), but that is a long way in the future if ever.

Keep in mind that the current version of the NEP may not be a good fit for pandas, because it requires overriding *all* NumPy functions. See this section of the NEP for details: 

Cheers,
Stephan

_______________________________________________
NumPy-Discussion mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/numpy-discussion
1234