[SciPy-user] [SciPy-dev] PyArray_New problem

Travis Oliphant oliphant.travis at ieee.org
Fri Dec 2 09:50:22 CST 2005

Robert Cimrman wrote:

>Could someone tell me what I am doing wrong? I would like to use a 
>function like the snippet below to create an array.
>PyArrayObject *helper_newCArrayObject_i32( int32 len, int32 *array ) {
>   intp plen[1];
>   PyArrayObject *obj = 0;
>   plen[0] = len;
>   printf( "11111 %d\n", PyArray_INT32 );
>/*   obj = (PyArrayObject *) PyArray_SimpleNew( 1, plen, PyArray_INT32 ); */
>   obj = (PyArrayObject *) PyArray_New( &PyArray_Type, 1, plen, 

First of all, don't pass in CARRAY_FLAGS when the data argument to 
PyArray_New is NULL.  A non-zero flags entry tells the subroutine to 
create a FORTRAN strides array if no data is passed.

Remember:  DATA flags are only to describe already available memory.   
If you create the memory  in PyArray_New, then the only thing to decide 
is FORTRAN or C- contiguous.   So, in this routine, you are creating a 
Fortran array.  Perhaps this is causing problems later.

Also, you are not showing us the rest of the code.  Your traceback is 
showing PyArray_ValidType being called which is not shown anywere...


More information about the SciPy-user mailing list