[Numpy-discussion] Subclassing numarray arrays.
Colin J. Williams
cjw at sympatico.ca
Wed Sep 24 04:32:01 EDT 2003
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+
> * 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".
>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:
>new_array = MyArray(zeros((10,5), type=Int64))
This is desirable, with the present design, one has to go through a two
new_array = MyArray(type=Int64, shape= (10, 5))
load_some_data_into_array(new_array, zeros(10, 5))
> Any comments?
>This sf.net email is sponsored by:ThinkGeek
>Welcome to geek heaven.
>Numpy-discussion mailing list
>Numpy-discussion at lists.sourceforge.net
More information about the NumPy-Discussion