colour.utilities.xp_ascontiguousarray#
- colour.utilities.xp_ascontiguousarray(a: ArrayLike, *, xp: ProtocolArrayNamespace | ModuleType | None = None) NDArray[source]#
Array API compatible implementation of
numpy.ascontiguousarray().Materialise
ainto a C-contiguous array with the same shape and dtype. The lazy stride-permuted view returned byxp.matrix_transpose()(and.T/.mT) poisons downstream broadcasts and forces BLAS to copy internally on every subsequentmatmul; calling this function at the transpose boundary cascades the contiguous layout through all downstream operations.- Parameters:
a (ArrayLike) – Variable \(a\) to materialise.
xp (ProtocolArrayNamespace | ModuleType | None) – Array namespace module. If None, derived from
a.
- Returns:
C-contiguous copy of \(a\) on the same backend.
- Return type:
Examples
>>> xp_ascontiguousarray(np.array([[1, 2], [3, 4]]).T, xp=np).flags["C_CONTIGUOUS"] True