|
From: Francesc A. <fa...@ca...> - 2005-11-02 08:37:19
|
Hi, I'm having problems in using the array protocol in numarray-->Numeric in some situations. I'm using the PyBuffer_FromReadWriteMemory C call in order to create buffers that will be later used to create numarray objects (both NumArray and CharArray) in Python space. The problem is that the array protocol implementation is doing badly this conversion. I was able to create a small example in pure python that reproduces the problem: >>> import numarray >>> from numarray import memory >>> import Numeric >>> na=3Dnumarray.array([1,2]) >>> Numeric.array(na) array([1, 2]) but ... >>> wbuf =3D memory.writeable_buffer(na) >>> nawb =3D numarray.array(wbuf,type=3D"Int32",shape=3D(2,)) >>> nawb array([1, 2]) >>> Numeric.array(nawb) array([ 2, 135510112]) I'm afraid that the problem should be related with the kind of buffer that is attached to the numarray object: >>> na._data <memory at 0x082577f8 with size:0x00000008 held by object 0x401f10a0 aliasing object 0x00000000> >>> nawb._data <read-write buffer for 0x401f10a0, size -1, offset 0 at 0x40572020> Travis, Todd, are you going to support read-write buffers or should I try to move to using the memory module in order to cope with this? For a series of reasons I'd like to keep using regular read-write buffers, but anyway... I think I'll be able to do the change if absolutely necessary. Thanks, --=20 >0,0< Francesc Altet http://www.carabos.com/ V V C=E1rabos Coop. V. Enjoy Data "-" |