
Hi! I have problem with this function call under FC6 X86_64 for my own numpy extension printf("\n %d %d %d", PyArray_DIM(imgi,0),PyArray_DIM(imgi, 1),PyArray_DIM(imgi,2)) it gave me 166 256 256 if I tried: int *dim; dim = PyArray_DIMS(imgi) printf("\n %d %d %d", dim[0], dim[1], dim[2]); it gave me 166 0 256 Numpy version: In [2]: numpy.__version__ Out[2]: '1.0.2.dev3487' I did test it under OS X 10.4.8 on MacPro. Those two methods gave me the exact results. So, what happens here ?? Gen-Nan Chen

Gennan Chen wrote:
Hi!
I have problem with this function call under FC6 X86_64 for my own numpy extension
printf("\n %d %d %d", PyArray_DIM(imgi,0),PyArray_DIM(imgi,1),PyArray_DIM(imgi,2))
it gave me
166 256 256
if I tried:
int *dim; dim = PyArray_DIMS(imgi) printf("\n %d %d %d", dim[0], dim[1], dim[2]);
it gave me 166 0 256
Numpy version:
In [2]: numpy.__version__ Out[2]: '1.0.2.dev3487'
I did test it under OS X 10.4.8 on MacPro. Those two methods gave me the exact results. So, what happens here ??
No idea. You should try PyArray_DIMS(imgi)[0], PyArray_DIMS(imgi)[1], PyArray_DIMS(imgi)[2] and see what that does. -Travis

Hi! On 12/20/06, Gennan Chen <gnchen@mac.com> wrote:
Hi!
I have problem with this function call under FC6 X86_64 for my own numpy extension
printf("\n %d %d %d", PyArray_DIM(imgi,0),PyArray_DIM(imgi,1),PyArray_DIM(imgi,2))
it gave me
166 256 256
if I tried:
int *dim; dim = PyArray_DIMS(imgi) printf("\n %d %d %d", dim[0], dim[1], dim[2]);
it gave me 166 0 256
Hi - maybe I'm dense here - but how is this /supposed/ to work ? Is PyArray_DIMS allocating some memory that never gets freed !? I thought "tuples" in C had to always be passed into a function, so that that function could modify it, as in: const int maxNDim = 20; int dim[maxNDim]; PyArray_DIMS(imgi, dim); --- What am I missing ... ? -Sebastian

On 12/20/06, Gennan Chen <gnchen@mac.com> wrote:
Hi!
I have problem with this function call under FC6 X86_64 for my own numpy extension
printf("\n %d %d %d", PyArray_DIM(imgi,0),PyArray_DIM(imgi,1),PyArray_DIM(imgi,2))
it gave me
166 256 256
if I tried:
int *dim; dim = PyArray_DIMS(imgi) printf("\n %d %d %d", dim[0], dim[1], dim[2]);
it gave me 166 0 256
Hi - maybe I'm dense here - but how is this /supposed/ to work ? Is PyArray_DIMS allocating some memory that never gets freed !? I thought "tuples" in C had to always be passed into a function, so that that function could modify it, as in: const int maxNDim = 20; int dim[maxNDim]; PyArray_DIMS(imgi, dim); What am I missing ... ? -Sebastian

Here is the definition of that call from ndarrayobject.h #define PyArray_DIMS(obj) (((PyArrayObject *)(obj))->dimensions) I believe the memory has been allocated. It just return a pointer. Gen On Dec 20, 2006, at 7:43 PM, Sebastian Haase wrote:
On 12/20/06, Gennan Chen <gnchen@mac.com> wrote: Hi!
I have problem with this function call under FC6 X86_64 for my own numpy extension
printf("\n %d %d %d", PyArray_DIM(imgi,0),PyArray_DIM(imgi, 1),PyArray_DIM(imgi,2))
it gave me
166 256 256
if I tried:
int *dim; dim = PyArray_DIMS(imgi) printf("\n %d %d %d", dim[0], dim[1], dim[2]);
it gave me 166 0 256
Hi - maybe I'm dense here - but how is this /supposed/ to work ? Is PyArray_DIMS allocating some memory that never gets freed !? I thought "tuples" in C had to always be passed into a function, so that that function could modify it, as in:
const int maxNDim = 20; int dim[maxNDim]; PyArray_DIMS(imgi, dim);
What am I missing ... ? -Sebastian
_______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
participants (4)
-
Gennan Chen
-
Sebastian Haase
-
Sebastian Haase
-
Travis Oliphant