def lerp(lower, upper, coord):
    """
    Linear interpolation.

    Given an upper and lower value and a coordinate between
    them interpolate between them. The assumption is that
    lower and upper are the values at two adjacent integer
    values thus the fractional part will tell you how close
    you are to the upper coordinate.

    Parameters
    ----------
    lower : number
    upper : number

    Return
    ------
    number
    """
    if isinstance(lower, tuple):
        # If is a tuple interpolate each value
        return tuple([lerp(c, d, coord) for c, d in zip(lower,upper)])
    ratio = coord % 1
    return int(round(lower * (1.0-ratio) + upper * ratio))