<commit_before>import numpy as np

try:
    import functools
    import quantities as pq
    from quantities.decorators import quantitizer as quant

    def quantitizer(handler):
        def dec(func):
            return quant(func, handler)
        return dec

    # Make a decorator to try to do appropriate unit conversion
    def check_units(**units):
        def decorator(func):
            @functools.wraps(func)
            def wrapper(*args, **kwargs):
                args = list(args)

                # By default, we do not want units back out
                returnUnits = False

                # Handle keyword args
                for kw,val in kwargs.items():
                    if isinstance(val, pq.Quantity):
                        # Since one was passed in, return a Quantity
                        returnUnits = True
                    else:
                        newUnits = units.get(kw, '')
                        kwargs[kw] = pq.Quantity(val, units=units[kw])

                # Now handle positional args by linking them in the order
                # given to the names in the code object.
                for argInd,(arg,val) in enumerate(
                        zip(func.func_code.co_varnames, args)):
                    if isinstance(val, pq.Quantity):
                        returnUnits = True
                    else:
                        newUnits = units.get(arg, '')
                        args[argInd] = pq.Quantity(val, units=newUnits)

                # Call the function
                ret = func(*args, **kwargs)

                # Make sure the returned type is appropriate
                if not returnUnits:
                    ret = ret.simplified.magnitude
                return ret
            return wrapper
        return decorator

    # Make a decorator to force the proper units if we're given a
    # quantity
    def force_units(return_units, **units):
        def decorator(func):
            @functools.wraps(func)
            def wrapper(*args, **kwargs):
                args = list(args)

                # By default, we do not want units back out
                returnUnits = False

                # Handle keyword args
                for kw,val in kwargs.items():
                    if isinstance(val, pq.Quantity):
                        # Since one was passed in, return a Quantity
                        returnUnits = True
                        newUnits = units.get(kw, '')
                        kwargs[kw] = val.rescale(newUnits).magnitude

                # Now handle positional args by linking them in the order<commit_msg>Map None to 'dimensionless' in return units in decorator.<commit_after>import numpy as np

try:
    import functools
    import quantities as pq
    from quantities.decorators import quantitizer as quant

    def quantitizer(handler):
        def dec(func):
            return quant(func, handler)
        return dec

    # Make a decorator to try to do appropriate unit conversion
    def check_units(**units):
        def decorator(func):
            @functools.wraps(func)
            def wrapper(*args, **kwargs):
                args = list(args)

                # By default, we do not want units back out
                returnUnits = False

                # Handle keyword args
                for kw,val in kwargs.items():
                    if isinstance(val, pq.Quantity):
                        # Since one was passed in, return a Quantity
                        returnUnits = True
                    else:
                        newUnits = units.get(kw, '')
                        kwargs[kw] = pq.Quantity(val, units=units[kw])

                # Now handle positional args by linking them in the order
                # given to the names in the code object.
                for argInd,(arg,val) in enumerate(
                        zip(func.func_code.co_varnames, args)):
                    if isinstance(val, pq.Quantity):
                        returnUnits = True
                    else:
                        newUnits = units.get(arg, '')
                        args[argInd] = pq.Quantity(val, units=newUnits)

                # Call the function
                ret = func(*args, **kwargs)

                # Make sure the returned type is appropriate
                if not returnUnits:
                    ret = ret.simplified.magnitude
                return ret
            return wrapper
        return decorator

    # Make a decorator to force the proper units if we're given a
    # quantity
    def force_units(return_units, **units):
        if return_units is None:
            return_units = 'dimensionless'
        def decorator(func):
            @functools.wraps(func)
            def wrapper(*args, **kwargs):
                args = list(args)

                # By default, we do not want units back out
                returnUnits = False

                # Handle keyword args
                for kw,val in kwargs.items():
                    if isinstance(val, pq.Quantity):
                        # Since one was passed in, return a Quantity
                        returnUnits = True
                        newUnits = units.get(kw, '')
                        kwargs[kw] = val.rescale(newUnits).magnitude

                # Now handle positional args by linking them in the order
{'fraction_non_alphanumeric': 0.06852128454070201, 'fraction_numerical': 0.0, 'mean_word_length': 1.3240780911062906, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5150963', 'n_tokens_mistral': 1328, 'n_tokens_neox': 1229, 'n_words': 435}