numpy.ma.squeeze

numpy.ma.squeeze(a)

Remove single-dimensional entries from the shape of an array.

Parameters :

a : array_like

Input data.

Returns :

squeezed : ndarray

The input array, but with with all dimensions of length 1 removed. Whenever possible, a view on a is returned.

Examples

>>> x = np.array([[[0], [1], [2]]])
>>> x.shape
(1, 3, 1)
>>> np.squeeze(x).shape
(3,)

Previous topic

numpy.ma.expand_dims

Next topic

numpy.ma.MaskedArray.squeeze

This Page