<commit_before># -*- coding: utf-8 -*-
#
import itertools
import numpy


def z(n):
    return numpy.zeros((1, n))


def fsd(n, r, d):
    '''Get all permutations of [+-r, +-r, 0, ..., 0] of length n, where +-r
    occurs d times.
    len(out) == 2**d * (n over d).
    n==1:  2*n
    n==2:  2*n*(n-1)
    n==3:  4*n*(n-1)*(n-2) / 3
    '''
    assert 0 <= d <= n
    return combine(((+r, -r), d), ((0.0,), n-d))


def fsd2(n, r, s, i, j):
    '''Get all permutations of [+-r, +-r, +-s, +-s, 0, ..., 0] of length n,
    with i times the number r and and j times the number s.
    '''
    assert i+j <= n
    return combine(((+r, -r), i), ((+s, -s), j), ((0.0,), n-i-j))


def combine(*elems):
    '''Given an input array with lists of options, e.g.,

    [[a, b], [c], [d]],

    this methods returns all combinations with one element from each
    subset, e.g.,

    [a, c, d], [a, d, c], [c, d, a], ...
    [b, c, d], [b, d, c], [c, d, b], ...
    '''
    # https://stackoverflow.com/a/45321972/353337<commit_msg>better doc<commit_after># -*- coding: utf-8 -*-
#
import itertools
import numpy


def z(n):
    return numpy.zeros((1, n))


def fsd(n, r, d):
    '''Get all permutations of [+-r, +-r, 0, ..., 0] of length n, where +-r
    occurs d times.
    len(out) == 2**d * (n over d).
    n==1:  2*n
    n==2:  2*n*(n-1)
    n==3:  4*n*(n-1)*(n-2) / 3
    '''
    assert 0 <= d <= n
    return combine(((+r, -r), d), ((0.0,), n-d))


def fsd2(n, r, s, i, j):
    '''Get all permutations of [+-r, +-r, +-s, +-s, 0, ..., 0] of length n,
    with i times the number r and and j times the number s.
    '''
    assert i+j <= n
    return combine(((+r, -r), i), ((+s, -s), j), ((0.0,), n-i-j))


def combine(*elems):
    '''Given an input array with lists of options, e.g.,

    ((+r, -r), 2), ((+s, -s), 2), ((0.0,), 1)

    this methods returns all combinations, i.e.,

    (+r, 0.0, -s, +r, +s),
    (0.0, -s, -r, +r, +s),
    ...
    '''
    # https://stackoverflow.com/a/45321972/353337
{'fraction_non_alphanumeric': 0.2513826043237808, 'fraction_numerical': 0.04172951231774761, 'mean_word_length': 2.1687898089171975, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '340138', 'n_tokens_mistral': 912, 'n_tokens_neox': 850, 'n_words': 278}