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

Hameer Abbasi einstein.edison at gmail.com
Fri May 18 10:04:03 EDT 2018


You can preserve this with (for example) __array_ufunc__. On
18/05/2018 at 18:57, Nathan wrote: I don't particularly need this,
although it would be nice to make this behavior explicit, instead of
happening more or less by accident: In [1]: from yt.units import km In
[2]: import numpy as np In [3]: data = [1, 2, 3]*km In [4]:
np.ones_like(data) Out[4]: YTArray([1., 1., 1.]) km On Fri, May 18,
2018 at 9:51 AM, Marten van Kerkwijk <m.h.vankerkwijk at gmail.com>
wrote: I'm greatly in favour, especially if the same can be done for
`zeros_like` and `empty_like`, but note that a tricky part is that
ufuncs do not deal very graciously with structured (void) and string
dtypes. -- Marten _______________________________________________
NumPy-Discussion mailing list NumPy-Discussion at python.org
https://mail.python.org/mailman/listinfo/numpy-discussion


More information about the NumPy-Discussion mailing list