def clamp(value, min_value, max_value):
    """Clamps a value witin the bound [min_value, max_value]

    Returns
    -------
    float
    """
    if min_value > max_value:
        raise ValueError('min_value must be bigger than max_value')
    return float(min(max(value, min_value), max_value))
