<commit_before>import glob
import json
import os

import experiment
import problem_generator
from algorithms import test


def iteration_func(i):
    return 100 + 2**i

algorithm_modules = [test]
local_limit = 5
global_limit = 100000
param_sets = [({'colors': i}, '{}.colors'.format(i)) for i in [3, 4]]


for problem_path in glob.iglob('problems/*'):
    problem_name = os.path.splitext(os.path.split(problem_path)[1])[0]
    for param_set, param_name in param_sets:
        with open(
            'results/{}_{}.json'.format(problem_name, param_name)
        ) as output_file:
            problem = problem_generator.read_graph_from_file(problem_path)
            json.dump(experiment.iterative(
                map(
                    lambda a: (a, param_set),
                    algorithm_modules
                ),
                problem,
                param_set,
                iteration_func,
                local_limit,
                global_limit
            ), output_file, indent=4)
<commit_msg>Fix problems in graph_color_experiment<commit_after>"""
Run final graph coloring experiments for all of the algorithms.
"""

import glob
import json
import os

import experiment
import problem_generator
from algorithms import test


def iteration_func(i):
    return 100 + 2**i

algorithm_modules = [test]
local_limit = 5
global_limit = 100000
param_sets = [({'colors': i}, '{}.colors'.format(i)) for i in [3, 4]]


for problem_path in glob.iglob('problems/*'):
    problem_path = os.path.split(problem_path)[1]
    problem_name = os.path.splitext(problem_path)[0]
    for param_set, param_name in param_sets:
        with open(
            'results/{}_{}.json'.format(problem_name, param_name), 'w'
        ) as output_file:
            print problem_path
            problem = problem_generator.read_graph_from_file(problem_path)
            json.dump(experiment.iterative(
                map(
                    lambda a: (a, param_set),
                    algorithm_modules
                ),
                problem,
                iteration_func,
                local_limit,
                global_limit
            ), output_file, indent=4)

{'fraction_non_alphanumeric': 0.09598523304107061, 'fraction_numerical': 0.014766958929395477, 'mean_word_length': 2.221396731054978, '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': '3386314', 'n_tokens_mistral': 661, 'n_tokens_neox': 607, 'n_words': 152}