Re: [Numpy-discussion] subclassing ndarray and recarray

2007-05-11 Thread Bernhard Voigt
Hi Pierre, that's great! I didn't do exactly what I wanted, but seeing how to overwrite the __getitem__ and __getslice__ methods I can adapt my class that it works with the use cases I need. Thanks for your help! Bernhard On 5/11/07, Pierre GM <[EMAIL PROTECTED]> wrote: Bernhard, Looks like y

Re: [Numpy-discussion] subclassing ndarray and recarray

2007-05-10 Thread Pierre GM
Bernhard, Looks like you have to modify your __getitem__ and __getslice__ methods. The following seems to work in simple cases. The numpy.array in front of numpy.ndarray.__getxxx__ is to transform the 'numpy.void def __getitem__(self, key): if isinstance(key, arraydict) and key.dtyp

Re: [Numpy-discussion] subclassing ndarray and recarray

2007-05-10 Thread Bernhard Voigt
Sorry for the spam, but I didn't modify the subject of the previous mail. Here's the message again but now with the right subject: Dear Pierre, I've attached the arraydict implementation file. You can run it and take a look at the following example on your own: In [25]: run arraydict.py create

Re: [Numpy-discussion] subclassing ndarray and recarray

2007-05-09 Thread Pierre GM
On Wednesday 09 May 2007 08:54:37 Bernhard Voigt wrote: > I'm trying to subclass ndarray or recarray to build a record array that has > a dictionary with a mapping of keys to array indexes and vice versa. Bernhard, Could you send me the rest of your code ? I'd like to test a couple of things bef

[Numpy-discussion] subclassing ndarray and recarray

2007-05-09 Thread Bernhard Voigt
I'm trying to subclass ndarray or recarray to build a record array that has a dictionary with a mapping of keys to array indexes and vice versa. I come across the problem, that depending on the field access method I get different types back: # a is a sublcass of record array print type(a) pr