[Numpy-discussion] Numpy array flags - BUG?

Thomas Hrabe thrabe@gmail....
Fri Sep 12 13:47:03 CDT 2008


Thank you, 
first tests work.
Thomas


Travis E. Oliphant wrote:
> 
> 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
> 
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
> 
> 

-- 
View this message in context: http://www.nabble.com/Numpy-array-flags---BUG--tp19444726p19461959.html
Sent from the Numpy-discussion mailing list archive at Nabble.com.



More information about the Numpy-discussion mailing list