[Numpy-discussion] Numpy array flags - BUG?

Travis E. Oliphant oliphant@enthought....
Thu Sep 11 19:35:03 CDT 2008


Thomas Hrabe wrote:
> Hello everyone,
>
> I must report odd behaviour of the numpy arrays regarding the flags set for
> each array object in C++.
> Please have a look at the following code:
>
> static PyObject* test(PyObject* self,PyObject* args){
>
>         int s[2];
>         s[0] = 1;
>         s[1] = 1;
>
>         char* value = (char*)PyMem_Malloc(2*sizeof(int));
>
>         PyObject* obj= PyArray_FromDimsAndData(1,s,NPY_INTLTR,(char*)value);
>         PyArrayObject* array = (PyArrayObject*) obj;
>         printf("%d\n",array->flags);
>         array->flags=0;
>         printf("%d\n",array->flags);
>         return obj;
> }
>   
You are using an old API and a new feature.    If you want to be able to 
create a Fortran array from data you need to use

PyArray_NewFromDescr

which allows setting flags.

-Travis



More information about the Numpy-discussion mailing list