def calc_bound ( end_point, tick_interval, is_upper ):
    """ Finds an axis end point that includes the value *end_point*.

    If the tick mark interval results in a tick mark hitting directly on the
    end point, *end_point* is returned.  Otherwise, the location of the tick
    mark just past *end_point* is returned. The *is_upper* parameter
    specifies whether *end_point* is at the upper (True) or lower (False)
    end of the axis.
    """
    quotient, remainder = divmod( end_point, tick_interval )
    if ((remainder == 0.0) or
        (((tick_interval - remainder) / tick_interval) < 0.00001)):
        return end_point

    c1 = (quotient + 1.0) * tick_interval
    c2 = quotient         * tick_interval
    if is_upper:
        return max( c1, c2 )
    return min( c1, c2 )