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.vankerkw...@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@python.org > https://mail.python.org/mailman/listinfo/numpy-discussion >
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@python.org https://mail.python.org/mailman/listinfo/numpy-discussion