colour.utilities.ndarray_write#

colour.utilities.ndarray_write(a: ArrayLike) Generator[source]#

Define a context manager setting given array \(a\) writeable to operate one and then read-only.

Parameters:

a (ArrayLike) – Array \(a\) to operate on.

Yields:

Generator – Array \(a\) operated.

Return type:

Generator

Examples

>>> a = np.linspace(0, 1, 10)
>>> a.setflags(write=False)
>>> try:
...     a += 1
... except ValueError:
...     pass
>>> with ndarray_write(a):
...     a += 1