def snap(self, xstep, ystep=None, padding=0.0):
        """
        Snap the rectangle onto a grid, with optional padding.

        :param xstep: The number of intervals to split the x=[0, 1] range into.
        :param ystep: The number of intervals to split the y=[0, 1] range into.
        :param padding: Uniform padding to add around the result. This shrinks
                        the result so that the edges + padding line up with the
                        grid.

        :returns: A new Rectangle, obtained by snapping self onto the grid,
                  and applying padding
        """

        if ystep is None:
            ystep = xstep

        return Rectangle(round(self.x * xstep) / xstep + padding,
                         round(self.y * ystep) / ystep + padding,
                         round(self.w * xstep) / xstep - 2 * padding,
                         round(self.h * ystep) / ystep - 2 * padding)
dataset/ETHPy150Open glue-viz/glue/glue/core/layout.py/Rectangle.snap/original