colour.utilities.ndarray_copy#

colour.utilities.ndarray_copy(a: ndarray[Any, dtype[_ScalarType_co]]) ndarray[Any, dtype[_ScalarType_co]][source]#

Return a numpy.ndarray copy if the relevant Colour state is enabled: Various API objects return a copy of their internal numpy.ndarray for safety purposes but this can be a slow operation impacting performance.

Parameters:

a (ndarray[Any, dtype[_ScalarType_co]]) – Array \(a\) to return a copy of.

Returns:

Array \(a\) copy according to Colour state.

Return type:

numpy.ndarray

Examples

>>> a = np.linspace(0, 1, 10)
>>> id(a) == id(ndarray_copy(a))
False
>>> with ndarray_copy_enable(False):
...     id(a) == id(ndarray_copy(a))
True