def assert_in_bounds(value, bounds):
    """Assert that a value is within a certain range.

    Parameters
    ----------
    value : int or float
        Value to test.
    bounds : tuple of int or float
        Lower and upper bound.

    Raises
    ------
    ValueError
        If the value is outside of the bounds.
    """
    try:
        min_val, max_val = bounds
    except (TypeError, ValueError):
        raise ValueError('bounds must be (min, max)')
    if min_val is not None and value < min_val:
        raise ValueError('value is below lower bound ({val} < {bound})'.
            format(val=value, bound=min_val))
    if max_val is not None and value > max_val:
        raise ValueError('value is above upper bound ({val} > {bound})'.
            format(val=value, bound=max_val))
