Subclassing Numeric arrays.

Colin J. Williams cjw at sympatico.ca
Wed Oct 15 10:27:31 EDT 2003


I haven't looked at Numeric for a while. Numarray 
http://stsdas.stsci.edu/numarray/Doc/index.html, which is under 
development to replace Numeric, has been modified to facilitate subclassing.

The basic problem remains, factory functions are used for instance 
creation, rather than the conventional class constructors.

It would help if there were some guidance with respect to pythonic ways 
of creating instances.  I posted an enquiry earlier this month: 
http://groups.google.ca/groups?q=python+numarray+sub-class&hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=3F7AFB07.1040206%40sympatico.ca&rnum=1

Colin W.

Lukasz Pankowski wrote:
> Jacek Generowicz <jacek.generowicz at cern.ch> writes:
> 
> 
>>[...]
>>Now, there is also a UserArray module in the Numeric distribution,
>>which, supposedly provides a subclassable analogue of the Numeric
>>arrays. But attempts to subclass it give an identical error message.
>>
>>So, what am I missing ?
> 
> 
> I suppose you subclassed UserArray.array which is the same function as
> Numeric.array. Subclassing UserArray.UserArray works:
> 
> 
>>>>import UserArray
>>>>class MyArray(UserArray.UserArray): pass
> 
> ...
> 
> 
>>>>import Numeric
>>>>UserArray.array is Numeric.array
> 
> True
> 





More information about the Python-list mailing list