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

Matthew Rocklin mrocklin at gmail.com
Mon May 21 12:01:04 EDT 2018


I've also posted a second issue on doing this at the module level (beyond
just ones_like) here: https://github.com/numpy/numpy/issues/11129

On Sat, May 19, 2018 at 9:12 PM, Marten van Kerkwijk <
m.h.vankerkwijk at gmail.com> wrote:

> Just for completeness: this is *not* an issue for ndarray subclasses,
> but only for people attempting to write duck arrays.  One might want
> to start by mimicking `empty_like` - not too different from
> `np.positive(a, where=False)`. Will note that that is 50 times slower
> for small arrays since it actually does the copying - it just doesn't
> store the results. It is comparable in time to np.zeros_like and
> np.ones_like, suggesting
> that a ufunc implementation is not necessarily a bad thing.
>
> As I noted above, the main problem I see is that the ufunc mechanism
> doesn't easily work with strings and voids/structured dtypes.
>
> -- Marten
> _______________________________________________
> 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/20180521/3551b8b6/attachment.html>


More information about the NumPy-Discussion mailing list