colour.utilities.xp_squeeze#

colour.utilities.xp_squeeze(a: ArrayLike, *, axis: int | tuple[int, ...] | None = None, xp: ProtocolArrayNamespace | ModuleType | None = None) NDArray[source]#

Squeeze size-1 dimensions from the specified array \(a\).

The Array API standard requires an explicit axis argument for squeeze(), unlike NumPy which allows omitting it to squeeze all size-1 dimensions. When axis is None, this helper computes the axes automatically.

Parameters:
Returns:

Squeezed array.

Return type:

object

Examples

>>> xp_squeeze(np.array([[1.0, 2.0]]), xp=np)
array([1., 2.])
>>> xp_squeeze(np.array([[[1.0], [2.0]]]), axis=-1, xp=np)
array([[1., 2.]])