|
From: Todd M. <jm...@st...> - 2005-11-10 16:47:50
|
Francesc Altet wrote: >El dv 04 de 11 del 2005 a les 15:35 -0500, en/na Todd Miller va >escriure: > > >>This turned out to be a problem with the way numarray handles Numeric's >>multi-segment buffer protocol. I worked around this by implementing >>David Cooke's __array_struct__ array interface for numarray. >> >> > >Did you commit the changes in CVS? I'm getting the same problems with >the current CVS version: > > > >>>>Numeric.__version__ >>>> >>>> >'24.1' > > >>>>import numarray >>>>numarray.__version__ >>>> >>>> >'1.4.2' > > >>>>num=Numeric.array([1,2,3,4]) >>>>numarray.array(num) >>>> >>>> >array([1, 2, 3, 4]) > > >>>>num2=num[::2] >>>>numarray.array(num2) >>>> >>>> >Traceback (most recent call last): > File "<stdin>", line 1, in ? > File "/usr/lib/python2.4/site-packages/numarray/numarraycore.py", line >380, in array > a = a.astype(type) > File "/usr/lib/python2.4/site-packages/numarray/numarraycore.py", line >867, in astype > return self.copy() > File "/usr/lib/python2.4/site-packages/numarray/numarraycore.py", line >927, in copy > c = _gen.NDArray.copy(self) > File "/usr/lib/python2.4/site-packages/numarray/generic.py", line 724, >in copy > arr._itemsize) >numarray.libnumarray.error: copy4bytes: access beyond buffer. offset=11 >buffersize=8 > > This turned out to be a bug in numarray buffer size determination... striding wasn't accounted for so the buffer appeared to be too small. It's fixed now in CVS. There's still a backward compatibility problem for old Numerics which don't implement __array_struct__ and get multi-segment buffers through __array_data__. Regards, Todd |