def clean_int(
    i: int,
    ub: int,
    lb: int = 0,
    ) -> int:
    """Clean an integer according to a given upper and lower bound

    Parameters
    ----------
    i : int
        The integer to be cleaned
    ub : int
        The inclusive upper bound
    lb : int, optional
        The exclusive lower bound, by default 0

    Returns
    -------
    int
        The cleaned integer
    """    

    #   Initialisations
    i_temp = i

    #   Check if the integer is above the upper bound
    if i_temp > ub:

        #   Set it to the upper bound
        i_temp = ub

    #   Check if the integer is below or equal to the lower bound
    elif i_temp <= lb:

        #   Set it to one above the lower bound
        i_temp = lb + 1

    return i_temp