[Numpy-discussion] Extent to which to work around matrix and other duck/subclass limitations

Marten van Kerkwijk m.h.vankerkwijk at gmail.com
Thu Jun 13 15:43:22 EDT 2019


Hi Ralf,


>> I guess the one immediate question is whether `np.sum` and the like
>> should be overridden by `__array_function__` at all, given that what should
>> be the future recommended override already works.
>>
>
> I'm not sure I understand the rationale for this. Design consistency
> matters. Right now the rule is simple: all ufuncs have __array_ufunc__, and
> other functions __array_function__. Why keep on tweaking things for little
> benefit?
>

I'm mostly trying to understand how we would actually change things. I
guess your quite logical argument for consistency is that it requires
`np.sum is np.add.reduce`. But to do that, one would have to get rid of the
`.sum()` method override, and then deprecate using `__array_function__` on
`np.sum`.

A perhaps clearer example is `np.isposinf`, where the implementation truly
consists of ufunc calls only (indeed, it is in `lib/ufunc_like`). I guess
following your consistency logic, one would not remove the
`__array_function__` override until it actually became a ufunc itself.

Anyway, I think this discussion has been useful, if only in making it yet
more clear how difficult it is to deprecate anything!

All the best,

Marten
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20190613/a90e3f2c/attachment.html>


More information about the NumPy-Discussion mailing list