1

I am working with python-c binding and I face with following problem. In python class there is a attribute called means which is numpy array of shape (2,3). If pInstance is PyObject* of that class, I wanted to do something like this:

PyObject* pMeans = PyObject_GetAttrString(pInstance,"means");
PyArrayObject* contig = (PyArrayObject*)PyArray_FromAny(pMeans,
PyArray_DescrFromType(NPY_DOUBLE),
    2, 3, NPY_ARRAY_CARRAY, NULL);

What I get is ValueError: object of too small depth for desired array. I also tried simple conversion:

PyArrayObject* contig = (PyArrayObject*)pMeans;

What is the proper eay to do this conversion?

user3616359
  • 359
  • 3
  • 20

0 Answers0