[Numpy-discussion] problem with integer type array object

Jin Woo Park jwpark at aeroguy.snu.ac.kr
Wed Mar 6 10:03:16 CST 2002

I was working on an external module build in C 
where a function returns a 2-D integer array.
However, when I imported module, I found a
strange behavior concerning the type of the element
of the array.
This is what basically happens:

static PyObject* foo(PyObject* arg, PyObject* args) {
    PyObject* a;
    int dims[2]={2,2};
    a = PyArray_FromDims(2,dims,PyArray_INT);
    return a;

in python, 
>>> a=foo()
>>> type(a[0,0])
<type 'array'>

I expected the type 'int'. 
If you make a Numpy array in python, then you get the expected
type of 'int'.
>>> b=array([[0,0],[0,0]])
>>> type(b[0,0])
<type 'int'>

Is this somehow intended? 
Thanks for any info,

| Jin Woo Park (jwpark at aeroguy.snu.ac.kr)|
| Research Assistant,Dept.Aerospace Eng. |
| Seoul National University, Korea       |

More information about the Numpy-discussion mailing list