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

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

        Returns
        -------
        squeezed : `RectGrid`
            Squeezed grid.

        Examples
        --------
        >>> g = RectGrid([0, 1], [-1], [-1, 0, 2])
        >>> g.squeeze()
        RectGrid(
            [ 0.,  1.],
            [-1.,  0.,  2.]
        )
        """
        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.nondegen_byaxis[i]]
        coord_vecs = [self.coord_vectors[axis] for axis in new_indcs]
        return RectGrid(*coord_vecs)
Return the grid with removed degenerate (length 1) dimensions.

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

        Returns
        -------
        squeezed : `RectGrid`
            Squeezed grid.

        Examples
        --------
        >>> g = RectGrid([0, 1], [-1], [-1, 0, 2])
        >>> g.squeeze()
        RectGrid(
            [ 0.,  1.],
            [-1.,  0.,  2.]
        )