Hi Will, We spent a *long time* sorting out the messy details of __array_ufunc__ [1], especially for handling interactions between different types, e.g., between numpy arrays, non-numpy array-like objects, builtin Python objects, objects that override arithmetic to act in non-numpy-like ways, and of course subclasses of all the above.
We hope that we have it right this time, but as we wrote in the NumPy 1.13 release notes "The API is provisional, we do not yet guarantee backward compatibility as modifications may be made pending feedback." That said, let's give it a try! If any changes are necessary, I expect it would likely relate to how we handle interactions between different types. That's where we spent the majority of the design effort, but debate is a poor substitute for experience. I would be very surprised if the basic cases (one argument or two arguments of the same type) need any changes. Best, Stephan [1] https://docs.scipy.org/doc/numpy-1.13.0/neps/ufunc-overrides.html On Fri, Oct 27, 2017 at 12:39 PM William Sheffler <willsheff...@gmail.com> wrote: > Right before 1.12, I arranged an API around an np.ndarray subclass, making > use of __array_ufunc__ to customize behavior based on structured dtype (we > come from c++ and really like operator overloading). Having seen > __array_ufunc__ featured in Travis Oliphant's Guide to NumPy: 2nd Edition, > I assumed this was the way to go. But it was removed in 1.12. Now that 1.13 > has reintroduced __array_ufunc__, can I now rely on its continued > availability? I am considering using it as a base-level component in > several libraries... is this a dangerous idea? > > Thanks! > Will > > -- > William H. Sheffler Ph.D. > Principal Engineer > Institute for Protein Design > University of Washington > _______________________________________________ > 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