<commit_before>import os
import logging
import socket
from dessn.framework.fitter import Fitter
from dessn.framework.models.approx_model import ApproximateModelOl
from dessn.framework.simulations.simple import SimpleSimulation

if __name__ == "__main__":
    logging.basicConfig(level=logging.DEBUG)
    plot_dir = os.path.dirname(os.path.abspath(__file__)) + "/plots/%s/" % os.path.basename(__file__)[:-3]
    dir_name = plot_dir + "output/"
    plot_filename = plot_dir + os.path.basename(__file__)[:-3]

    file = os.path.abspath(__file__)
    print(dir_name)

    if not os.path.exists(dir_name):
        os.makedirs(dir_name)

    num_nodes = 4
    model = ApproximateModelOl(num_nodes=num_nodes, global_calibration=1)
    simulation = [SimpleSimulation(300, alpha_c=0, mass=True, dscale=0.08, num_nodes=num_nodes),
                  SimpleSimulation(200, alpha_c=0, mass=True, dscale=0.08, num_nodes=num_nodes, lowz=True)]
    fitter = Fitter(dir_name)
    fitter.set_models(model)
    fitter.set_simulations(simulation)
    fitter.set_num_cosmologies(225)
    fitter.set_num_walkers(1)
    fitter.set_max_steps(5000)

    h = socket.gethostname()
    if h != "smp-hk5pn72":  # The hostname of my laptop. Only will work for me, ha!
        fitter.fit(file)
    else:
        from chainconsumer import ChainConsumer
        m, s, chain, truth, weight, old_weight, posterior = fitter.load()

        print("Plotting posteriors")
        c = ChainConsumer()
        c.add_chain(chain, weights=weight, posterior=posterior, name="Approx")
        c.configure(spacing=1.0, diagonal_tick_labels=False, sigma2d=False, contour_labels="confidence")
        parameters = [r"$\Omega_m$", r"$\Omega_\Lambda$"]
        print(c.analysis.get_latex_table(transpose=True))
        with open(plot_filename + "_cosmo_params.txt", 'w') as f:
            f.write(c.analysis.get_latex_table(parameters=parameters))
        c.plotter.plot(filename=plot_filename + "_cosmo.png", truth=truth, parameters=parameters, figsize="column")
        c.plotter.plot(filename=plot_filename + "_cosmo.pdf", truth=truth, parameters=parameters, figsize="column")<commit_msg>More supernova in the approx simple ol test<commit_after>import os
import logging
import socket
from dessn.framework.fitter import Fitter
from dessn.framework.models.approx_model import ApproximateModelOl
from dessn.framework.simulations.simple import SimpleSimulation

if __name__ == "__main__":
    logging.basicConfig(level=logging.DEBUG)
    plot_dir = os.path.dirname(os.path.abspath(__file__)) + "/plots/%s/" % os.path.basename(__file__)[:-3]
    dir_name = plot_dir + "output/"
    plot_filename = plot_dir + os.path.basename(__file__)[:-3]

    file = os.path.abspath(__file__)
    print(dir_name)

    if not os.path.exists(dir_name):
        os.makedirs(dir_name)

    num_nodes = 4
    model = ApproximateModelOl(num_nodes=num_nodes, global_calibration=1)
    simulation = [SimpleSimulation(700, alpha_c=0, mass=True, dscale=0.08, num_nodes=num_nodes),
                  SimpleSimulation(300, alpha_c=0, mass=True, dscale=0.08, num_nodes=num_nodes, lowz=True)]
    fitter = Fitter(dir_name)
    fitter.set_models(model)
    fitter.set_simulations(simulation)
    fitter.set_num_cosmologies(225)
    fitter.set_num_walkers(1)
    fitter.set_max_steps(5000)

    h = socket.gethostname()
    if h != "smp-hk5pn72":  # The hostname of my laptop. Only will work for me, ha!
        fitter.fit(file)
    else:
        from chainconsumer import ChainConsumer
        m, s, chain, truth, weight, old_weight, posterior = fitter.load()

        print("Plotting posteriors")
        c = ChainConsumer()
        c.add_chain(chain, weights=weight, posterior=posterior, name="Approx")
        c.configure(spacing=1.0, diagonal_tick_labels=False, sigma2d=False, contour_labels="confidence")
        parameters = [r"$\Omega_m$", r"$\Omega_\Lambda$"]
        print(c.analysis.get_latex_table(transpose=True))
        with open(plot_filename + "_cosmo_params.txt", 'w') as f:
            f.write(c.analysis.get_latex_table(parameters=parameters))
        c.plotter.plot(filename=plot_filename + "_cosmo.png", truth=truth, parameters=parameters, figsize="column")
        c.plotter.plot(filename=plot_filename + "_cosmo.pdf", truth=truth, parameters=parameters, figsize="column")
{'fraction_non_alphanumeric': 0.1214649976819657, 'fraction_numerical': 0.01483541956420955, 'mean_word_length': 4.052693208430913, 'pattern_counts': {'":': 4, '<': 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': '4886110', 'n_tokens_mistral': 1484, 'n_tokens_neox': 1423, 'n_words': 258}