def Clamp(num, a, b):
    """
    Returns ``a`` if ``num`` is smaller than
    or equal to ``a``, ``b`` if ``num`` is
    greater than or equal to ``b``, or ``num``
    if it is between ``a`` and ``b``.

    Parameters
    ----------
    num : float
        Input number
    a : float
        Lower bound
    b : float
        Upper bound

    """
    return min(max(num, a), b)