cf.Data.squeeze

Data.squeeze(axes=None)[source]

Remove size 1 dimensions from the data in place.

Parameters :
axes : (sequence of) int or str

The axes to be squeezed. May be one of, or a sequence of any combination of zero or more of:

  • The integer position of a dimension in the data array (negative indices allowed).
  • The internal name a dimension.

No dimensions are squeezed if an empty sequence is given.

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.to_disk

This Page