<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def dimension_range(lower, upper, hard_range, soft_range, padding=None, log=False):
 """ Computes the range along a dimension by combining the data range with the Dimension soft_range and range. """

    lower, upper = range_pad(lower, upper, padding, log)
    lower = max_range([(lower, None), (soft_range[0], None)])[0]
    upper = max_range([(None, upper), (None, soft_range[1])])[1]
    dmin, dmax = hard_range
    lower = lower if dmin is None or not isfinite(dmin) else dmin
    upper = upper if dmax is None or not isfinite(dmax) else dmax
    return lower, upper