[Numpy-discussion] Subclassing numarray arrays

Nadav Horesh nadavh at VisionSense.com
Thu Sep 25 00:26:05 CDT 2003


On Wed, 2003-09-24 at 14:31, Colin J. Williams wrote:
> Nadav Horesh wrote:
>
> >Recently I had an idea to subclass numarray's array in order to
> >implement a different scheme of array indexing via the __call__
method
> >(ugly indeed, by my experience shows that it can be useful). It
occurred
> >to me that the array class is not in the spirit of Python 2.2+
> >classes/types unification:
> >
> I agree.
>
> >      * The class name is not "trivial": numarraycore.NumArray
> >      * The class constructor is not built to be used by the commons.
> >
> I'm not sure what you have in mind here by "trivial" and "commons".

commons == End users whose most scripts life-time is few days.
trivial == A name one would expect, like "Array" or similar.

>
> >Since arrays are normally generated by functions (zeros, array,
> >fromfunction etc.) and not by the constructor, subclassing
> >numarraycore.NumArray is not very useful. If, for instance, "array"
(or
> >"Array") would be the class name, where the constructor would
optionally
> >have the same parameters as the array function (with the option to
act
> >as a copy constructor as the array function does), then it would be
easy
> >to subclass it:
> >
> >class MyArray(array):
> >  ...
> >
> >
> >new_array = MyArray(zeros((10,5), type=Int64))
> >
> > 
> >
> This is desirable, with the present design, one has to go through a
two
> step process:
>
> new_array = MyArray(type=Int64, shape= (10, 5))
> load_some_data_into_array(new_array, zeros(10, 5))
>  
> Colin W.

As I recall, one of the targets of the numarray project is to be
included as a standard python library --- shouldn't it eventually comply
with the new-classes standard?

>
> >  Any comments?
> >
> >   Nadav.
> >
> >
> >
> >-------------------------------------------------------
> >This sf.net email is sponsored by:ThinkGeek
> >Welcome to geek heaven.
> >http://thinkgeek.com/sf
> >_______________________________________________
> >Numpy-discussion mailing list
> >Numpy-discussion at lists.sourceforge.net
> >https://lists.sourceforge.net/lists/listinfo/numpy-discussion
> >
> > 
> >
>
>





More information about the Numpy-discussion mailing list