<commit_before>import json

def avg(iterable):
    return sum(iterable) / len(iterable)

def nice_json_dump(data, filepath):
    with open(filepath, 'w') as f:
        json.dump(data, f, sort_keys=True, indent=4, separators=(',', ': '))
<commit_msg>Make avg() work with iterators<commit_after>import json

def avg(iterable):
    sum_ = 0
    element_count = 0
    for element in iterable:
        sum_ += element
        element_count += 1
    return sum_ / element_count

def nice_json_dump(data, filepath):
    with open(filepath, 'w') as f:
        json.dump(data, f, sort_keys=True, indent=4, separators=(',', ': '))

{'fraction_non_alphanumeric': 0.13687600644122383, 'fraction_numerical': 0.008051529790660225, 'mean_word_length': 3.6074074074074076, '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': '1255545', 'n_tokens_mistral': 222, 'n_tokens_neox': 216, 'n_words': 56}