Re: [Numpy-discussion] subclassing ndarray and keeping same ufunc behavior

2016-11-15 Thread Stuart Reynolds
Doh! Thanks for that. On Tue, Nov 15, 2016 at 10:48 AM, Marten van Kerkwijk < m.h.vankerkw...@gmail.com> wrote: > Hi Stuart, > > It certainly seems correct behaviour to return the subclass you > created: after all, you might want to keep the information on > `columns` (e.g., consider doing nanmin

Re: [Numpy-discussion] subclassing ndarray and keeping same ufunc behavior

2016-11-15 Thread Nathan Goldbaum
You might also want to consider writing a wrapper object that contains an ndarray as a (possibly private) attribute and then presents different views or interpretations of that array. Subclassing ndarray is a pit of snakes, it's best to avoid it if you can (I say as the author and maintainer of an

Re: [Numpy-discussion] subclassing ndarray and keeping same ufunc behavior

2016-11-15 Thread Marten van Kerkwijk
Hi Stuart, It certainly seems correct behaviour to return the subclass you created: after all, you might want to keep the information on `columns` (e.g., consider doing nanmin along a given axis). Indeed, we certainly want to keep the unit in astropy's Quantity (which also is a subclass of ndarray

[Numpy-discussion] subclassing ndarray and keeping same ufunc behavior

2016-11-15 Thread Stuart Reynolds
I'm trying to subclass an ndarray so that I can add some additional fields. When I do this however, I get new odd behavior when my object is passed to a variety of numpy functions. For example nanmin returns now return an object of the type of my new array class, whereas previously I'd get a float6