<commit_before>"""Collections
"""

from __future__ import absolute_import

import random

from .utilities import matches, property_, callback as make_callback
from .utils import iter_callback, iter_


def at(collection, *indexes):  # pylint: disable=invalid-name
    """Creates an array of elements from the specified indexes, or keys, of the
    collection. Indexes may be specified as individual arguments or as arrays
    of indexes.

    :param iterable collection: the collection to iterate over
    :param mixed indexes: the indexes of `collection` to retrieve, specified as
                          individual indexes or arrays of indexes
    """
    # FIXME: Resolve circular imports
    from .arrays import flatten

    indexes = flatten(indexes)
    return [collection[i] for i in indexes]


def contains(collection, target, from_index=0):
    """Checks if a given value is present in a collection using strict equality
    for comparisons, i.e. ===. If `from_index` is negative, it is used as the
    offset from the end of the collection.
    """
    if isinstance(collection, dict):
        collection = collection.values()
    else:
        # only makes sense to do this if `collection` is not a dict
        collection = collection[from_index:]

    return target in collection


include = contains


def count_by(collection, callback):
    """Creates an object composed of keys generated from the results of running
    each element of `collection` through the callback.
    """
    ret = dict()
    cbk = make_callback(callback)

    for value in collection:<commit_msg>Resolve circular imports.<commit_after>"""Collections
"""

from __future__ import absolute_import

import random

from .arrays import flatten
from .utilities import matches, property_, callback as make_callback
from .utils import iter_callback, iter_


def at(collection, *indexes):  # pylint: disable=invalid-name
    """Creates an array of elements from the specified indexes, or keys, of the
    collection. Indexes may be specified as individual arguments or as arrays
    of indexes.

    :param iterable collection: the collection to iterate over
    :param mixed indexes: the indexes of `collection` to retrieve, specified as
                          individual indexes or arrays of indexes
    """
    indexes = flatten(indexes)
    return [collection[i] for i in indexes]


def contains(collection, target, from_index=0):
    """Checks if a given value is present in a collection using strict equality
    for comparisons, i.e. ===. If `from_index` is negative, it is used as the
    offset from the end of the collection.
    """
    if isinstance(collection, dict):
        collection = collection.values()
    else:
        # only makes sense to do this if `collection` is not a dict
        collection = collection[from_index:]

    return target in collection


include = contains


def count_by(collection, callback):
    """Creates an object composed of keys generated from the results of running
    each element of `collection` through the callback.
    """
    ret = dict()
    cbk = make_callback(callback)

    for value in collection:
{'fraction_non_alphanumeric': 0.06963434022257552, 'fraction_numerical': 0.0006359300476947536, 'mean_word_length': 3.345303867403315, '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': '5356905', 'n_tokens_mistral': 816, 'n_tokens_neox': 778, 'n_words': 365}