colour.utilities.xp_round#
- colour.utilities.xp_round(a: ArrayLike, *, decimals: int = 0, xp: ProtocolArrayNamespace | ModuleType | None = None) NDArrayFloat[source]#
Array API compatible implementation of
numpy.round()with decimals.The Array API standard
xp.rounddoes not accept a decimals parameter. This helper uses the backend’s nativeroundwhen it supports decimals (JAX, CuPy), otherwise falls back to a multiply-round-divide pattern using the standardxp.round.- Parameters:
a (ArrayLike) – Array to round.
decimals (int) – Number of decimal places.
xp (ProtocolArrayNamespace | ModuleType | None) – Array namespace module. If None, derived from
a.
- Returns:
Rounded array.
- Return type: