squeeze

Contents

squeeze#

class brainunit.math.squeeze(a, axis=None, **kwargs)#

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

Parameters:
  • a (Array | saiunit.Quantity) – Input data.

  • axis (int | Tuple[int, ...] | None) – 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.

Returns:

res – An array with the same data as a, but with a lower dimension.

Return type:

Array | saiunit.Quantity

Examples

>>> import saiunit as u
>>> a = [[[1], [2], [3]]] * u.second
>>> u.math.squeeze(a).shape
(3,)