colour.utilities.xp_linspace#

colour.utilities.xp_linspace(start: ArrayLike, stop: ArrayLike, *, num: int = 50, xp: ProtocolArrayNamespace | ModuleType | None = None, like: Any = None, **kwargs: Any) NDArrayFloat | tuple[NDArrayFloat, float][source]#

Array API compatible implementation of numpy.linspace() with extra keyword arguments such as retstep and dtype.

The Array API standard xp.linspace does not accept retstep. This helper tries the backend’s native linspace first, falling back to NumPy if the keyword is unsupported.

Parameters:
  • start (ArrayLike) – Start of the interval.

  • stop (ArrayLike) – End of the interval.

  • num (int) – Number of samples.

  • xp (ProtocolArrayNamespace | ModuleType | None) – Array namespace module. If None, derived from start and stop.

  • like (Any) – Reference array whose device to match (for backends like PyTorch that support multiple devices); the result is created on that device rather than the backend’s default.

  • **kwargs (Any) – Extra keyword arguments (e.g., retstep, dtype).

Returns:

Array of evenly spaced values (and step size if retstep=True).

Return type:

object