Does astype make sense as a ufunc? Aaron Meurer
On Tue, Jul 11, 2023 at 7:38 AM James Webber <jamestweb...@gmail.com> wrote: > > Hello there! First time posting here and I apologize if this discussion is > not new. I couldn't find it in a search. > > I've been contributing a bit to the sparse project > (https://github.com/pydata/sparse) and I was working on specializing the > behavior for single-argument ufuncs, because there is a faster path for some > sparse arrays if the indexes don't change at all. > > As I was working on this I noticed that `sparse` uses `__array_ufunc__` on > some non-ufunc methods, like `round`, `clip`, and `astype`, which caused some > bugs in my initial attempt. This is easy enough to fix in the package, but it > made me wonder if those functions _could_ or _should_ be ufuncs in numpy > itself. > > The full list for the sparse library is `clip`, `round`, `astype`, `real`, > and `imag`. There might be other candidates in numpy, those are just the ones > in this project. > > The benefit I see is that an implementor of `__array_ufunc__` wouldn't need > to implement these methods. But perhaps their interfaces are too complex for > ufunc-iness? > _______________________________________________ > NumPy-Discussion mailing list -- numpy-discussion@python.org > To unsubscribe send an email to numpy-discussion-le...@python.org > https://mail.python.org/mailman3/lists/numpy-discussion.python.org/ > Member address: asmeu...@gmail.com _______________________________________________ NumPy-Discussion mailing list -- numpy-discussion@python.org To unsubscribe send an email to numpy-discussion-le...@python.org https://mail.python.org/mailman3/lists/numpy-discussion.python.org/ Member address: arch...@mail-archive.com