def clamp(value, min_=0., max_=1.):
    """Clip a value to a range [min, max].

    :param value: The value to clip
    :param min_: The min edge of the range
    :param max_: The max edge of the range
    :return: The clipped value
    """
    if value < min_:
        return min_
    elif value > max_:
        return max_
    else:
        return value