def mat_approx_equal(x, y, tol=1e-5):
    """Returns True if each cell in 2D iterable matrix ``x`` differs by less than
    ``tol`` from the corresponding element in ``y``
    """
    if len(x) != len(y):
        return False
    for row_x, row_y in zip(x, y):
        if len(row_x) != len(row_y):
            return False
        for i, j in zip(row_x, row_y):
            if abs(i - j) >= tol:
                return False
    return True