def round2ArbatraryBase(value, direction, roundingBase):
    """Round value up or down to arbitrary base

    Parameters
    ----------
    value : float
        Value to be rounded.

    direction : str
        Round up, down to the nearest base (choices: "up","down","nearest")

    roundingBase : int
        rounding base. (Example: if base = 5, values will be rounded to the nearest multiple of 5 or 10.)

    Returns
    -------
    rv : int
        rounded value.
    """
    if direction.lower().startswith("u"):
        rv = value + (roundingBase - value % roundingBase)  # round up to nearest base
    elif direction.lower().startswith("d"):
        rv = value - value % roundingBase  # round down to nearest base
    else:
        rv = int(roundingBase * round(float(value) / roundingBase))  # round up or down to nearest base
    return rv