RectPartition.squeeze

RectPartition.squeeze(self, axis=None)[source]

Return the partition with removed degenerate (length 1) dimensions.

Parameters
axisNone or index expression, optional

Subset of the axes to squeeze. Default: All axes.

Returns
squeezedRectPartition

Squeezed partition.

Notes

This is not equivalent to RectPartiton(self.set.squeeze(), self.grid.squeeze()) since the definition of degenerate is different in sets and grids. This method follow the definition used in grids, that is, an axis is degenerate if it has only one element.

Examples

>>> p = odl.uniform_partition([0, -1], [1, 2], (3, 1))
>>> p.squeeze()
uniform_partition(0.0, 1.0, 3)

The axis argument can be used to only squeeze some axes (if applicable)

>>> p.squeeze(axis=0)
uniform_partition([ 0., -1.], [ 1.,  2.], (3, 1))