[Numpy-discussion] Experimental `like=` attribute for array creation functions

Sebastian Berg sebastian at sipsolutions.net
Mon Aug 10 11:30:23 EDT 2020


Hi all,

as a heads up that Peter Entschev has a PR open to add `like=` to
most array creation functions, my current plan is to merge it soon as a preliminary API and bring it up again before the actual release (in a few months).  This allows overriding for array-likes, e.g. it will allow:

   
    arr = np.asarray([3], like=dask_array)
    type(arr) is dask.array.Array

This was proposed in NEP 35:

https://numpy.org/neps/nep-0035-array-creation-dispatch-with-array-function.html

Although that has not been accepted as of now, the PR is:

https://github.com/numpy/numpy/pull/16935


This was discussed in a smaller group, and is an attempt to see how we
can make the array-function protocol viable to allow packages such as
sklearn to work with non-NumPy arrays.

As of now, this would be experimental and can revisit it before the
actual NumPy release.  We should probably discuss accepting NEP 35
more. At this time, I hope that we can put in the functionality to
facilitate this discussion, rather the other way around.

If anyone feels nervous about this step, I would be happy to document
that we will not include it in the next release unless the NEP is
accepted first, or at least hide it behind an environment variable.

Cheers,

Sebastian

-------------- 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/20200810/cb16d8dd/attachment.sig>


More information about the NumPy-Discussion mailing list