colour.utilities.ndarray_write¶
-
colour.utilities.
ndarray_write
(a)[source]¶ A context manager setting given array writeable to perform an operation and then read-only.
- Parameters
a (array_like) – Array to perform an operation.
- Returns
Array.
- Return type
ndarray
Examples
>>> a = np.linspace(0, 1, 10) >>> a.setflags(write=False) >>> try: ... a += 1 ... except ValueError: ... pass >>> with ndarray_write(a): ... a +=1