def snap_to_grid(rectangles, padding=0.0):
    result = {}
    xs, ys = _snap_size(rectangles)
    for r in rectangles:
        result[r] = r.snap(xs, ys, padding=padding)
    return result
Snap a collection of rectangles onto a grid, in a sensible fashion
dataset/ETHPy150Open glue-viz/glue/glue/core/layout.py/snap_to_grid