[Numpy-discussion] Turn numpy.ones_like into a ufunc

Matthew Rocklin mrocklin at gmail.com
Fri May 18 08:28:02 EDT 2018


Hi All,

I would like to see the numpy.ones_like function operate as a ufunc.  This
is currently done in np.core.umath._ones_like.  This was recently raised
and discussed in https://github.com/numpy/numpy/issues/11074 .  It was
suggested that I raise the topic here instead.

My understanding is that this was considered some time ago, but that the
current numpy.ones_like function was implemented instead.  No one on that
issue seems to fully remember why.  Perhaps someone here has a longer
memory?

My objective for defaulting to the ufunc implementation is that it makes it
compatible with other projects that implement numpy-like interfaces
(dask.array, sparse, cupy) so that downstream projects can use a subset of
numpy code that is valid across a few projects.  More broadly I would like
to see ufuncs and other protocol-enabled functions start to become more
common within numpy, ones_like being one specific case.

Best,
-matt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20180518/a6a0b45a/attachment-0001.html>


More information about the NumPy-Discussion mailing list