def squeeze(self, axis=None):
        """Return the partition with removed degenerate (length 1) dimensions.

        Parameters
        ----------
        axis : None or index expression, optional
            Subset of the axes to squeeze. Default: All axes.

        Returns
        -------
        squeezed : `RectPartition`
            Squeezed partition.

        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))

        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.

        See Also
        --------
        odl.discr.grid.RectGrid.squeeze
        odl.set.domain.IntervalProd.squeeze
        """
        if axis is None:
            rng = range(self.ndim)
        else:
            rng = list(np.atleast_1d(np.arange(self.ndim)[axis]))

        new_indcs = [i for i in range(self.ndim)
                     if i not in rng or self.grid.nondegen_byaxis[i]]
        newset = self.set[new_indcs]
        return RectPartition(newset, self.grid.squeeze(axis))
Return the partition with removed degenerate (length 1) dimensions.

        Parameters
        ----------
        axis : None or index expression, optional
            Subset of the axes to squeeze. Default: All axes.

        Returns
        -------
        squeezed : `RectPartition`
            Squeezed partition.

        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))

        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.

        See Also
        --------
        odl.discr.grid.RectGrid.squeeze
        odl.set.domain.IntervalProd.squeeze