For a simulation project I am working on I've subclasses ArrayType. I was able to do much of my intentions until in one place when I tried to make an array from a list of arrays I got an error message: . . . File "/usr/local/lib/python2.3/site-packages/numarray/numarraycore.py", line 325, in array return fromlist(sequence, type, shape) File "/usr/local/lib/python2.3/site-packages/numarray/numarraycore.py", line 212, in fromlist a = a.astype(type) File "/usr/local/lib/python2.3/site-packages/numarray/numarraycore.py", line 630, in astype retarr = self.__class__(buffer=None, shape=self._shape, type=type) TypeError: __init__() got an unexpected keyword argument 'buffer' The analysis of the code showed that: 1. The NumArray class method definitions depends on the _PROTOTYPE flag 2. The post-mortem debugging showed that when the error flagged, the value of the variable _PROTOTYPE was 0 In a stand alone script there was no problem to do the list-> array conversion:
import numarray as N import NumImage as NI # My module with the derived class a = N.arange(4) ia = NI.Cimage(N.arange(4)) # CImage is a derivative of NumImage a array([0, 1, 2, 3]) ia Cimage([0, 1, 2, 3]) N.array([a+i for i in range(3)]) array([[0, 1, 2, 3], [1, 2, 3, 4], [2, 3, 4, 5]]) N.array([ia+i for i in range(3)]) # OK here, but failed as a part of a complex script Cimage([[0, 1, 2, 3], [1, 2, 3, 4], [2, 3, 4, 5]])
My questions are: 1. Is this flag is in use? If I set it to 0 will I be able to derive a class from the "C code"? 2. Any intelligent solution? Nadav.