<commit_before># Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from functools import partial, wraps
import inspect

from cytoolz import pluck
from cytoolz.utils import no_default


def as_method(o):
    if inspect.ismethod(o):
        return o
    else:
        @wraps(o)
        def proxy(*args, **kwargs):
            return o(*args, **kwargs)
        return proxy


class ppluck(object):
    def __init__(self, ind, seqs, default=no_default):
        self.ind = ind
        self.seqs = seqs
        self.default = default

    def __iter__(self):
        return pluck(self.ind, self.seqs, self.default)

    def __reduce__(self):
        return identity, (tuple(iter(self)),)


def partial_func(func, *args, **kwargs):
    if args:
        if kwargs:
            return partial(func, *args, **kwargs)
        else:
            return partial(func, *args)
    elif kwargs:
        return partial(func, **kwargs)
    else:
        return func


def _getter(key, obj):
    return obj[key]


def _getter_list(index, obj):
    return tuple(obj[i] for i in index)<commit_msg>utils for moving between variadic functions and those with a fixed arity<commit_after># Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from functools import partial, wraps
import inspect

from cytoolz import pluck
from cytoolz.utils import no_default


def as_method(o):
    if inspect.ismethod(o):
        return o
    else:
        @wraps(o)
        def proxy(*args, **kwargs):
            return o(*args, **kwargs)
        return proxy


class ppluck(object):
    def __init__(self, ind, seqs, default=no_default):
        self.ind = ind
        self.seqs = seqs
        self.default = default

    def __iter__(self):
        return pluck(self.ind, self.seqs, self.default)

    def __reduce__(self):
        return identity, (tuple(iter(self)),)


def partial_func(func, *args, **kwargs):
    if args:
        if kwargs:
            return partial(func, *args, **kwargs)
        else:
            return partial(func, *args)
    elif kwargs:
        return partial(func, **kwargs)
    else:
        return func


class variadic(object):
    def __init__(self, func, *args, **kwargs):
        self.func = func
        self.args = args
        self.kwargs = kwargs

    def __call__(self, *args, **kwargs):
        kwargs = dict(self.kwargs, **kwargs)
        return self.func(args, *self.args, **kwargs)


class unvariadic(object):
    def __init__(self, func, *args, **kwargs):
        self.func = func
        self.args = args
        self.kwargs = kwargs

    def __call__(self, args, **kwargs):
        kwargs = dict(self.kwargs, **kwargs)
        args = tuple(args) + self.args
        return self.func(*args, **kwargs)


def _getter(key, obj):
    return obj[key]


def _getter_list(index, obj):
    return tuple(obj[i] for i in index)
{'fraction_non_alphanumeric': 0.09816272965879265, 'fraction_numerical': 0.002099737532808399, 'mean_word_length': 2.8186372745490984, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1026219', 'n_tokens_mistral': 1118, 'n_tokens_neox': 1099, 'n_words': 404}