def clamp(x, minimum=0., maximum=1.):
    """
    args:
        x: float
        minimum: float
        maximum: float
    returns: float between [minimum, maximum]
    """
    return max(minimum, min(x, maximum))