[Numpy-discussion] removing undocumented use of __array__(dtype, context)

Sebastian Berg sebastian at sipsolutions.net
Wed Dec 18 15:08:41 EST 2019


On Mon, 2019-12-16 at 13:41 -0600, Sebastian Berg wrote:
> 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.
> > 

Just to note, our plan is to merge this in a few days, since it seems
like the only way to find out if someone might be using it is to put it
in. We do not expect this at all.

If anyone disagrees or finds a use-case, we can always stop or revert
the change. But such changes will be nicer now that 1.18 is just
branched rather than in a few months.

Best,

Sebastian


> > 
> > 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
> 
> _______________________________________________
> 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/20191218/923f1a1e/attachment.sig>


More information about the NumPy-Discussion mailing list