[Numpy-discussion] Please help - pointer to slice

Sebastian Haase haase at msg.ucsf.edu
Thu Mar 6 16:43:06 EST 2003


Hi,
I am using SWIG to wrap some C++ function operating on numarray arrays.
Everything works quite well -- up until yesterday...

I have some 3d data and was thinking if the actual operation I want to do is
done "slice by slice", I could just loop over Z in python and have my C
function
defined like this:
void DoSomething(float * array2d, int nx, int ny)

The python loop looks like this:
arr = numarray.array(shape=(100,100,100), type=numarray.Float32)
for z in range(nz):
     DoSomething( arr[z] )

SOMEHOW the pointer that get transfered to the C++ side is always the same
as
for the  full (3d) array.

if I try to debug this by doing:
for z in range(nz):
    print repr(arr[z]._data)

that also tells be that python / numarray thinks all slices are located at
the same address, that is:
every slice looks just like the full array.

Please help,  I don't know what to do...

Sebastian Haase







More information about the NumPy-Discussion mailing list