numpy.ndarray.flags

ndarray.flags

Information about the memory layout of the array.

Attributes:

C_CONTIGUOUS (C) :

The data is in a single, C-style contiguous segment.

F_CONTIGUOUS (F) :

The data is in a single, Fortran-style contiguous segment.

OWNDATA (O) :

The array owns the memory it uses or borrows it from another object.

WRITEABLE (W) :

The data area can be written to.

ALIGNED (A) :

The data and strides are aligned appropriately for the hardware.

UPDATEIFCOPY (U) :

This array is a copy of some other array. When this array is deallocated, the base array will be updated with the contents of this array.

FNC :

F_CONTIGUOUS and not C_CONTIGUOUS.

FORC :

F_CONTIGUOUS or C_CONTIGUOUS (one-segment test).

BEHAVED (B) :

ALIGNED and WRITEABLE.

CARRAY (CA) :

BEHAVED and C_CONTIGUOUS.

FARRAY (FA) :

BEHAVED and F_CONTIGUOUS and not C_CONTIGUOUS.

Notes

The flags object can be also accessed dictionary-like, and using lowercased attribute names. Short flag names are only supported in dictionary access.

Only the UPDATEIFCOPY, WRITEABLE, and ALIGNED flags can be changed by the user, via assigning to flags['FLAGNAME'] or ndarray.setflags. The array flags cannot be set arbitrarily:

  • UPDATEIFCOPY can only be set False.
  • ALIGNED can only be set True if the data is truly aligned.
  • WRITEABLE can only be set True if the array owns its own memory or the ultimate owner of the memory exposes a writeable buffer interface or is a string.

Previous topic

numpy.ndarray

Next topic

numpy.ndarray.shape

This Page

Quick search