cf.Data.squeeze

Data.squeeze(axes=None)[source]

Remove size 1 axes from the data array in place.

By default all size 1 axes are removed, but particular axes may be selected with the keyword arguments.

Parameters :
axes : (sequence of) int or str, optional

Select the axes. By default all size 1 axes are removed. The axes argument may be one, or a sequence, of:

  • An internal axis identifier. Selects this axis.
  • An integer. Selects the axis coresponding to the given position in the list of axes of the data array.

No axes are removed if axes is an empty sequence.

Returns :
out : list of ints

The axes which were squeezed as a tuple of their positions.

Examples

>>> v.shape
(1,)
>>> v.squeeze()
>>> v.shape
()
>>> v.shape
(1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1)
>>> v.squeeze((0,))
>>> v.shape
(2, 1, 3, 1, 4, 1, 5, 1, 6, 1)
>>> v.squeeze(1)
>>> v.shape
(2, 3, 1, 4, 1, 5, 1, 6, 1)
>>> v.squeeze([2, 4])
>>> v.shape
(2, 3, 4, 5, 1, 6, 1)
>>> v.squeeze([])
>>> v.shape
(2, 3, 4, 5, 1, 6, 1)
>>> v.squeeze()
>>> v.shape
(2, 3, 4, 5, 6)

Previous topic

cf.Data.sin

Next topic

cf.Data.tan

This Page