masked_array.setflags(write=None,align=None,uic=None)¶Set array flags WRITEABLE, ALIGNED, 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 UPDATEIFCOPY flag can never be set to True. The flag WRITEABLEcan only be set to True if the array owns its own memory, or theultimate owner of the memory exposes a writeable buffer interface,or is a string. (The exception for string is made so that unpicklingcan be done without copying memory.)
| Parameters: | write : bool, optional
align : bool, optional
uic : bool, optional
|
|---|
Notes
Array flags provide information about how the memory area usedfor the array is to be interpreted. There are 6 Boolean flagsin use, only three of which can be changed by the user: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) this array is a copy of some other array (referencedby .base). When this array is deallocated, the base array will beupdated with the contents of this array.
All flags can be accessed using their first (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 UPDATEIFCOPY : False>>>y.setflags(write=0,align=0)>>>y.flags C_CONTIGUOUS : True F_CONTIGUOUS : False OWNDATA : True WRITEABLE : False ALIGNED : False UPDATEIFCOPY : False>>>y.setflags(uic=1)Traceback (most recent call last): File"<stdin>", line1, in<module>ValueError:cannot set UPDATEIFCOPY flag to True