[Numpy-discussion] Revised NEP-18, array_function protocol (original) (raw)

Eric Wieser wieser.eric+numpy at gmail.com
Thu Jun 28 20:35:17 EDT 2018


Another option would be to directly compare the methods against known ones:

obj = func.self if isinstance(obj, np.ufunc): if func is obj.reduce: got_reduction()

Eric ​

On Thu, 28 Jun 2018 at 17:19 Stephan Hoyer <shoyer at gmail.com> wrote:

On Thu, Jun 28, 2018 at 1:12 PM Marten van Kerkwijk <_ _m.h.vankerkwijk at gmail.com> wrote:

For C classes like the ufuncs, it seems _self_ is defined for methods as well (at least, np.add.reduce._self_ gives np.add), but not a _func_. There is a _name_ (="reduce"), though, which means that I think one can still retrieve what is needed (obviously, this also means _arrayufunc_ could have been simpler...)

Good point! I guess this means we should encourage using name rather than func. I would not want to preclude refactoring classes from Python to C/Cython.


NumPy-Discussion mailing list NumPy-Discussion at python.org https://mail.python.org/mailman/listinfo/numpy-discussion -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20180628/966183f0/attachment-0001.html>



More information about the NumPy-Discussion mailing list