Académique Documents
Professionnel Documents
Culture Documents
These macros all access the PyArrayObject structure members. The input argument,
arr, can be any PyObject * that is directly interpretable as a PyArrayObject * (any
instance of the PyArray_Type and its sub-types).
A synonym for PyArray_DIMS, named to be consistent with the shape usage within
Python.
If you are constructing an array using the C API, and specifying your own memory,
you should use the function PyArray_SetBaseObject to set the base to an object
which owns the memory.
A synonym for PyArray_DESCR, named to be consistent with the dtype usage within
Python.
Enables the specified array flags. This function does no validation, and assumes
that you know what youre doing.
Clears the specified array flags. This function does no validation, and assumes
that you know what youre doing.
Note that, in the old API that was deprecated in version 1.7, this function had the
return type int.
Data access
These functions and macros provide easy access to elements of the ndarray from C.
These work for all arrays. You may need to take care when accessing the data in the
array, however, if it is not in machine byte-order, misaligned, or not writeable.
In other words, be sure to respect the state of the flags unless you know what you
are doing, or have previously guaranteed an array that is writeable, aligned, and
in machine byte-order using PyArray_FromAny. If you wish to handle all types of
arrays, the copyswap function for each type is useful for handling misbehaved
arrays. Some platforms (e.g. Solaris) do not like misaligned data and will crash if
you de-reference a misaligned pointer. Other platforms (e.g. x86 Linux) will just
work more slowly with misaligned data.