Test that the length of the data items fall within range: low <= x <= high.

    If high is None, treat as exact length.

def bounded_length(low, high=None):
    """Test that the length of the data items fall within range: low <= x <= high.

    If high is None, treat as exact length.
    """
    def decorator(function):
        """Decorate a function with args."""
        @functools.wraps(function)
        def wrapper(*args, **kwargs):
            """Wrap the function."""
            series = function(*args, **kwargs)
            if high is None:
                return series.apply(lambda x: len(x) == low)
            else:
                lo_pass = series.apply(lambda x: low <= len(x))
                hi_pass = series.apply(lambda x: len(x) <= high)

                return lo_pass & hi_pass

        return wrapper

    return decorator