[Numpy-discussion] zero values in the output of PyArray_AsCArray(

Boukhdhir Amal boukhdhiramal at yahoo.fr
Tue Feb 7 17:40:46 EST 2017

 I am trying to access an array as a C-Type using the function 'PyArray_AsCArray'The problem is that I am getting many 0 values in the resulting C- array. Some of the indexedvalues are correct.
This is my code: 
static PyObject* cos_func_np(PyObject* self, PyObject* args){        PyObject *in_array_object;        PyObject *out_array;          int** segs_2d_array;                      /* Parse single numpy array argument*/        if (! PyArg_ParseTuple(args, "O", &in_array_object))            return NULL;        int typenum = NPY_INT64;        PyArray_Descr *descr;        descr = PyArray_DescrFromType(typenum);                                     npy_intp dims[2];                              PyArray_AsCArray(&in_array_object, (void**) &segs_2d_array, dims, 2, descr);                
        printf("\n-segs_2d_array: %d --\n", segs_2d_array[1][5]);                                         //return Py_BuildValue("O", in_array_object);        }
For example:segs_2d_array[0][0]  and segs_2d_array[1][2] outputs the correct values, however, segs_2d_array[1][3] and segs_2d_array[1][5] are equal to zero.

What is wrong with this code please ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20170207/f0e0eb19/attachment.html>

More information about the NumPy-Discussion mailing list