[Numpy-discussion] Subclassing numarray arrays.

Nadav Horesh nadavh at VisionSense.com
Wed Sep 24 00:15:05 CDT 2003


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:
      * The class name is not "trivial": numarraycore.NumArray
      * The class constructor is not built to be used by the 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:

class MyArray(array):
  ...


new_array = MyArray(zeros((10,5), type=Int64))


  Any comments?

   Nadav.





More information about the Numpy-discussion mailing list