squeeze#
- IndexSetND.squeeze(*indices, names=None)#
Squeeze the IndexSet for given dimension indices to get a new IndexSet.
- Parameters:
- *indicesint
Dimension indices i.e., position indices of N-dim to squeeze.
- namessequence[str], optional
Names to refer to each dimension of the squeezed elements.
- Returns:
- IndexSet1D or IndexSetND
- Raises:
- LookupError
If the IndexSet is empty.
- ValueError
If no dimension index is given or all dimension indices are given.
- ValueError
If any dimension index is invalid (exceeds the length of N-dim tuple element).
- ValueError
If the names sequence has multiple elements when squeezing for one dimension index.
Examples
>>> triple = IndexSetND([('A', 0, 0), ('A', 1, 2), ('B', 1, 2)])
Squeeze for the first dimension index:
>>> triple.squeeze(0, names=['letter']) IndexSet1D: (letter) ['A', 'B']
Squeeze for the second and third dimension indices:
>>> triple.squeeze(1, 2, names=['one', 'two']) IndexSetND: (one, two) [(0, 0), (1, 2)]