colour_visuals.common.as_contiguous_array#

class colour_visuals.common.as_contiguous_array(a: NDArray, dtype: Type[DType] = DEFAULT_FLOAT_DTYPE_WGPU)[source]#

Bases:

Convert given array to a contiguous array (ndim >= 1) in memory (C order).

Parameters:
  • a (NDArray) – Variable \(a\) to convert.

  • dtype (Type[DType]) – numpy.dtype to use for conversion, default to the numpy.dtype defined by the colour.constant.DEFAULT_FLOAT_DTYPE_WGPU attribute.

Returns:

Converted variable \(a\).

Return type:

numpy.ndarray

Examples

>>> a = np.ones((2, 3), order="F")
>>> a.flags
  C_CONTIGUOUS : False
  F_CONTIGUOUS : True
  OWNDATA : True
  WRITEABLE : True
  ALIGNED : True
  WRITEBACKIFCOPY : False

>>> as_contiguous_array(a).flags
  C_CONTIGUOUS : True
  F_CONTIGUOUS : False
  OWNDATA : True
  WRITEABLE : True
  ALIGNED : True
  WRITEBACKIFCOPY : False