- nlcpy.squeeze(a, axis=None)
Removes single-dimensional entries from the shape of an array.
- axisNone or int or tuple of ints, optional
Selects a subset of the single-dimensional entries in the shape. If an axis is selected with shape entry greater than one, an error is raised.
The input array, but with all or a subset of the dimensions of length 1 removed. This is always a itself or a view into a.
>>> import nlcpy as vp >>> x = vp.array([[, , ]]) >>> x.shape (1, 3, 1) >>> vp.squeeze(x).shape (3,) >>> vp.squeeze(x, axis=0).shape (3, 1) >>> vp.squeeze(x, axis=1).shape Traceback (most recent call last): ... ValueError: cannot select an axis to squeeze out which has size not equal to one >>> vp.squeeze(x, axis=2).shape (1, 3)