chararray.setflags(write=None,align=None,uic=None)¶Set array flags WRITEABLE, ALIGNED, (WRITEBACKIFCOPY and UPDATEIFCOPY),respectively.
These Boolean-valued flags affect how numpy interprets the memoryarea used bya (see Notes below). The ALIGNED flag can onlybe set to True if the data is actually aligned according to the type.The WRITEBACKIFCOPY and (deprecated) UPDATEIFCOPY flags can never be setto True. The flag WRITEABLE can only be set to True if the array owns itsown memory, or the ultimate owner of the memory exposes a writeable bufferinterface, or is a string. (The exception for string is made so thatunpickling can be done without copying memory.)
| Parameters: |
|
|---|
Notes
Array flags provide information about how the memory area usedfor the array is to be interpreted. There are 7 Boolean flagsin use, only four of which can be changed by the user:WRITEBACKIFCOPY, UPDATEIFCOPY, WRITEABLE, and ALIGNED.
WRITEABLE (W) the data area can be written to;
ALIGNED (A) the data and strides are aligned appropriately for the hardware(as determined by the compiler);
UPDATEIFCOPY (U) (deprecated), replaced by WRITEBACKIFCOPY;
WRITEBACKIFCOPY (X) this array is a copy of some other array (referencedby .base). When the C-API function PyArray_ResolveWritebackIfCopy iscalled, the base array will be updated with the contents of this array.
All flags can be accessed using the single (upper case) letter as wellas the full name.
Examples
>>>yarray([[3, 1, 7], [2, 0, 0], [8, 5, 9]])>>>y.flags C_CONTIGUOUS : True F_CONTIGUOUS : False OWNDATA : True WRITEABLE : True ALIGNED : True WRITEBACKIFCOPY : False UPDATEIFCOPY : False>>>y.setflags(write=0,align=0)>>>y.flags C_CONTIGUOUS : True F_CONTIGUOUS : False OWNDATA : True WRITEABLE : False ALIGNED : False WRITEBACKIFCOPY : False UPDATEIFCOPY : False>>>y.setflags(uic=1)Traceback (most recent call last): File"<stdin>", line1, in<module>ValueError:cannot set WRITEBACKIFCOPY flag to True