def scale(val, src, dst):
    """
    Scale value from src range to dst range.
    If value outside bounds, it is clipped and set to
    the low or high bound of dst.

    Ex:
        scale(0, (0.0, 99.0), (-1.0, 1.0)) == -1.0
        scale(-5, (0.0, 99.0), (-1.0, 1.0)) == -1.0

    """
    if val < src[0]:
        return dst[0]
    if val > src[1]:
        return dst[1]

    return ((src[0] - val) / (src[1] - src[0])) * (dst[1] - dst[0]) + dst[0]
dataset/ETHPy150Open pmorissette/ffn/ffn/utils.py/scale/swapped operands of `-`