squeeze¶
- squeeze(x: array, /, axis: int | Tuple[int, ...]) array ¶
Removes singleton axes from
x
.- Parameters:
x (array) – input array.
axis (Union[int, Tuple[int, ...]]) – axis (or axes) to squeeze. A valid axis must be an integer on the interval
[-N, N)
, whereN
is the number of axes inx
. If an axis is specified as a negative integer, the function must determine the axis along which to perform the operation by counting backward from the last axis (where-1
refers to the last axis). If provided an invalid axis, the function must raise an exception.
- Returns:
out (array) – an output array. The returned array must have the same data type and the same elements as
x
.- Raises:
ValueError – If a specified axis has a size greater than one (i.e., it is not a singleton axis), a
ValueError
should be raised.