[Numpy-discussion] removing undocumented use of __array__(dtype, context)
Sebastian Berg
sebastian at sipsolutions.net
Mon Dec 16 14:41:37 EST 2019
On Mon, 2019-12-16 at 21:01 +0200, Matti Picus wrote:
> A code path and test have been in the code since NumPy 0.4 for a
> two-argument variant of ``__array__(dtype=None, context=None)``. It
> was
> activated when calling ``ufunc(op)`` or ``ufunc.reduce(op)`` if
> ``op.__array__`` existed. However that variant is not documented, and
> it
> is not clear what the intention was for its use.
>
>
> The code was something like
>
>
> try:
>
> op.__array__(dtype, context)
>
> except TypeError:
>
> op.__array__(dtype)
>
>
> In PR 15118 https://github.com/numpy/numpy/pull/15118 I proposed to
> remove this, so the call is now simply
>
>
> op.__array__(dtype)
>
>
> or `op.__array__()` if there is no dtype
>
>
> Does anyone need the undocumented two-argument variant?
>
I agree, if nobody knows any usecase, I am for trying to remove it. It
seems like a Deprecation will not be super simple here. And since there
are no known use-cases, and any new use-case is better covered by
`__array_ufunc__` (and probably also `__array_wrap__`), removing this
simplifies an already tricky enough corner of NumPy.
Best,
Sebastian
>
> Matti
>
>
>
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at python.org
> https://mail.python.org/mailman/listinfo/numpy-discussion
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20191216/e35abc32/attachment.sig>
More information about the NumPy-Discussion
mailing list