PyArray_FromDimsAndData weird seg fault
Hi, I'm using SWIG to wrap a function that calls the NumPy routine PyArray_FromDimsAndData. PyObject* toArray() { int dims = 5; double* myH; myH = (double*)malloc(dims*sizeof(double)); myH[0] = 0; myH[1] = 1; myH[2] = 2; myH[3] = 3; myH[4] = 4; return PyArray_FromDimsAndData(1,&dims,PyArray_FLOAT,(char*)myH); } However, for some reason when I call this from Python, the PyArray_FromDimsAndData() seg faults everytime. Does anybody see something wrong with my use of the function itself? Thanks! -Trevor -- ************************************************************* Trevor M. Cickovski Laboratory For Computational Life Sciences University of Notre Dame 325 Cushing Hall Notre Dame, IN 46556 T: (574) 631-3906 F: (574) 631-9260 "Settle never, strive always." *************************************************************
Trevor M Cickovski wrote:
Hi,
I'm using SWIG to wrap a function that calls the NumPy routine PyArray_FromDimsAndData.
PyObject* toArray() { int dims = 5; double* myH; myH = (double*)malloc(dims*sizeof(double)); myH[0] = 0; myH[1] = 1; myH[2] = 2; myH[3] = 3; myH[4] = 4; return PyArray_FromDimsAndData(1,&dims,PyArray_FLOAT,(char*)myH); }
However, for some reason when I call this from Python, the PyArray_FromDimsAndData() seg faults everytime. Does anybody see something wrong with my use of the function itself?
Did you call import_array() in your module initialization function? -Travis
participants (2)
-
Travis Oliphant
-
Trevor M Cickovski