[Numpy-discussion] Adding to the non-dispatched implementation of NumPy methods

Ralf Gommers ralf.gommers at gmail.com
Sun Apr 28 13:10:57 EDT 2019


On Sun, Apr 28, 2019 at 6:57 PM Marten van Kerkwijk <
m.h.vankerkwijk at gmail.com> wrote:

> Hi Ralf,
>
> Agreed that the coercion right now is *not* generic, with some doing
> `asarray`, others `asanyarray` and yet others nothing. There are multiple
> possible solutions, with one indeed being that for each function one moves
> the coercion bits out to an associated intermediate function. In principle,
> as I mentioned above, one could then think of letting that intermediate
> function take on a coercion function (i.e., `asarray`, `asanyarray` or even
> any one's favourite coercion function), which might make it possible to
> generate them semi-automatically.
>
> Anyway, as said, mostly I want to be sure we leave ourselves the freedom
> to experiment with that as well, and not get bound by `__wrapped__` or
> `__numpy_implementation__` becoming effectively a second layer of API.
>

Well, it is becoming a second layer of API:) Just with clearly articulated
guarantees. I think we're on the same wavelength now.

Thanks,
Ralf


But for actual experiments, it may well be better to try `__array_ufunc__`
> first, as for ufuncs coercion is uniform.
>
> All the best,
>
> Marten
>
> p.s. Good point also about checking of non-array inputs.
> _______________________________________________
> 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/20190428/20d58f3d/attachment-0001.html>


More information about the NumPy-Discussion mailing list