def bounded_length(low, high=None):
def decorator(function):<EOL><INDENT>"""<STR_LIT>"""<EOL>@functools.wraps(function)<EOL>def wrapper(*args, **kwargs):<EOL><INDENT>"""<STR_LIT>"""<EOL>series = function(*args, **kwargs)<EOL>if high is None:<EOL><INDENT>return series.apply(lambda x: len(x) == low)<EOL><DEDENT>else:<EOL><INDENT>lo_pass = series.apply(lambda x: low <= len(x))<EOL>hi_pass = series.apply(lambda x: len(x) <= high)<EOL>return lo_pass & hi_pass<EOL><DEDENT><DEDENT>return wrapper<EOL><DEDENT>return decorator<EOL>
Test that the length of the data items fall within range: low <= x <= high.

    If high is None, treat as exact length.