Re: [Numpy-discussion] ndarray: subclassing a subclass looses custom attribute

2010-10-01 Thread Sebastian Haase
On Fri, Oct 1, 2010 at 2:20 PM, Pierre GM wrote: > > On Oct 1, 2010, at 1:03 PM, Sebastian Haase wrote: > However, I had done this before for some specific image-file-types: those would add there own attribute to ndarray array (e.g. arr.Mrc) Now if I call the new  ndarray_meta on my

Re: [Numpy-discussion] ndarray: subclassing a subclass looses custom attribute

2010-10-01 Thread Pierre GM
On Oct 1, 2010, at 1:03 PM, Sebastian Haase wrote: >>> However, I had done this before for some specific image-file-types: >>> those would add there own attribute to ndarray array (e.g. arr.Mrc) >>> Now if I call the new ndarray_meta on my ndarray_with_mrc I loose the >>> `Mrc` attribute, leavin

Re: [Numpy-discussion] ndarray: subclassing a subclass looses custom attribute

2010-10-01 Thread Sebastian Haase
On Fri, Oct 1, 2010 at 12:38 PM, Pierre GM wrote: > > On Oct 1, 2010, at 11:26 AM, Sebastian Haase wrote: > >> Hi, >> I'm trying to add a 'meta' attribute to ndarray to keep track of image >> data filenames and resolution etc. >> Following  the excellent document >> http://docs.scipy.org/doc/numpy

Re: [Numpy-discussion] ndarray: subclassing a subclass looses custom attribute

2010-10-01 Thread Pierre GM
On Oct 1, 2010, at 11:26 AM, Sebastian Haase wrote: > Hi, > I'm trying to add a 'meta' attribute to ndarray to keep track of image > data filenames and resolution etc. > Following the excellent document > http://docs.scipy.org/doc/numpy/user/basics.subclassing.html > this worked right away. > >

Re: [Numpy-discussion] ndarray: subclassing a subclass looses custom attribute

2010-10-01 Thread Sebastian Haase
On Fri, Oct 1, 2010 at 11:26 AM, Sebastian Haase wrote: > Hi, > I'm trying to add a 'meta' attribute to ndarray to keep track of image > data filenames and resolution etc. > Following  the excellent document > http://docs.scipy.org/doc/numpy/user/basics.subclassing.html > this worked right away. >

[Numpy-discussion] ndarray: subclassing a subclass looses custom attribute

2010-10-01 Thread Sebastian Haase
Hi, I'm trying to add a 'meta' attribute to ndarray to keep track of image data filenames and resolution etc. Following the excellent document http://docs.scipy.org/doc/numpy/user/basics.subclassing.html this worked right away. However, I had done this before for some specific image-file-types: t

Re: [Numpy-discussion] ndarray subclassing bug?

2008-08-10 Thread Christoph T. Weidemann
On Sun, Aug 10, you wrote: > What functionality, may I ask ? I am working on a dimensioned array data structure that is a subclass of ndarray and lets you keep track of the different dimensions of an array, assign labels to them (and the different levels on each dimensions) and allows for smart in

Re: [Numpy-discussion] ndarray subclassing bug?

2008-08-10 Thread Pierre GM
On Sunday 10 August 2008 15:50:15 Christoph T. Weidemann wrote: > Pierre, > Thanks for the fast and informative answers! Sorry again for the confusion, the first answer was definitely too fast... > I used the base attribute to call ndarray functions on > my derived class and obviously that faile

Re: [Numpy-discussion] ndarray subclassing bug?

2008-08-10 Thread Christoph T. Weidemann
Pierre, Thanks for the fast and informative answers! On Sun you wrote: > So no, you didn't do anything wrong. What behavior were you expecting ? I was expecting that calls to self.base would produce identical results for objects of the TestArray class, no matter how these calls are triggered. I

Re: [Numpy-discussion] ndarray subclassing bug?

2008-08-10 Thread Pierre GM
On Sunday 10 August 2008 14:26:33 Christoph T. Weidemann wrote: > Why whould tst.sort() show the correct base class and np.sort show > NoneType as base class for tst? > I'd appreciate any insights ... Christoph, I should take the time to read the question first before answering. So, according to

Re: [Numpy-discussion] ndarray subclassing bug?

2008-08-10 Thread Christoph T. Weidemann
You wrote: > numpy functions will return arrays of the type which has the largest priority, > with ndarrays a priority of 1 by default. If you set a Class variable > __array_priority__ to a number larger than 1, that should fix your problem. The following code produces the same behavior: import n

Re: [Numpy-discussion] ndarray subclassing bug?

2008-08-10 Thread Pierre GM
On Sunday 10 August 2008 14:26:33 Christoph T. Weidemann wrote: > Why whould tst.sort() show the correct base class and np.sort show > NoneType as base class for tst? > I'd appreciate any insights ... numpy functions will return arrays of the type which has the largest priority, with ndarrays a p

[Numpy-discussion] ndarray subclassing bug?

2008-08-10 Thread Christoph T. Weidemann
I've come across a strange behavior for classes subclassed from ndarray. Here's a minimal example that illustrates the problem: import numpy as np class TestArray(np.ndarray): def __new__(cls, data, info=None, dtype=None, copy=False): subarr = np.array(data, dtype=dtype, copy=copy)

Re: [Numpy-discussion] ndarray subclassing

2008-04-30 Thread ctw
On Thu, May 1, 2008, Travis E. Oliphant wrote: > You are just seeing the result of __repr__. The printing code works by > accessing slices of the array. These slices create new instances of > your TestArray class which have a smaller number of dimensions. That's all. Ahh, that makes sense. Th

Re: [Numpy-discussion] ndarray subclassing

2008-04-30 Thread Travis E. Oliphant
ctw wrote: > Hi! > > I ran into some strange (at least to me) issues with sublasses of > ndarray. The following minimal class definition illustrates the > problem: > > > > import numpy as np > class TestArray(np.ndarray): > def __new__(cls, d

[Numpy-discussion] ndarray subclassing

2008-04-30 Thread ctw
Hi! I ran into some strange (at least to me) issues with sublasses of ndarray. The following minimal class definition illustrates the problem: import numpy as np class TestArray(np.ndarray): def __new__(cls, data, info=None, dtype=None, co