[Numpy-discussion] PyArray_New bug?

Travis E. Oliphant oliphant@enthought....
Sat Oct 4 11:24:48 CDT 2008


Ravi wrote:
> Hi,
>   PyArray_New seems to return a fortran contiguous array regardless of the 
> requested array type. I am using numpy version 1.1.1.
>
> PyObject *obj = PyArray_New( &PyArray_Type, 2, dims, /*whatever*/, NULL,
>                                  NULL, 0, NPY_CARRAY, NULL );
> PyObject *obj = PyArray_New( &PyArray_Type, 2, dims, /*whatever*/, NULL,
>                                  NULL, 0, NPY_FARRAY, NULL );
>
> Both the above return a array who PyArray_ISFORTRAN( obj ) succeeds. I can 
> verify this by checking bits 0 and 1 (LSB is bit 0) of PyArray_FLAGS.
>
>   
The C-API for PyArray_New is not what you were expecting.    When data 
is NULL so that NumPy creates the array, then the flags argument is a 
toggle switch (i.e. any non-zero value for the flags argument means 
construct a Fortran array).

Sorry for the confusion.

-Travis



More information about the Numpy-discussion mailing list