<commit_before>
from __future__ import absolute_import, print_function

from .fitting import spotted_transit_model, spotted_transit_model_individuals
from .storage import read_results_archive
from .lightcurve import TransitLightCurve

import matplotlib.pyplot as plt
from corner import corner


class MCMCResults(object):
    def __init__(self, archive_path):

        results = read_results_archive(archive_path)
        self.lnprob, self.best_params, self.chains, lc_matrix = results

        self.lc = TransitLightCurve(times=lc_matrix[0, :],
                                    fluxes=lc_matrix[1, :],
                                    errors=lc_matrix[2, :])

    def plot_lnprob(self):
        plt.figure()
        plt.title('$\log \,p$')
        plt.plot(self.lnprob)
        plt.xlabel('Step')
        plt.ylabel('$\log \,p$')

    def plot_corner(self):
        plt.figure()
        labels = ['depth']
        for i in range(self.chains.shape[0]):
            labels.extend(['$a_{0}$'.format(i), '$t_{{0,{0}}}$'.format(i),
                           '$\sigma_{0}$'.format(i)])
        corner(self.chains, labels=labels)

    def plot_max_lnp_lc(self, transit_params):
        model = spotted_transit_model(self.best_params, self.lc.times.jd,
                                      transit_params)
        individual_models = spotted_transit_model_individuals(self.best_params,
                                                              self.lc.times.jd,
                                                              transit_params)

        errorbar_props = dict(fmt='.', color='k', capsize=0, ecolor='gray')

        fig, ax = plt.subplots(2, 1, figsize=(8, 10), sharex=True)

        min_jd_int = int(self.lc.times.jd.min())
        ax[0].errorbar(self.lc.times.jd - min_jd_int, self.lc.fluxes,
                       self.lc.errors, **errorbar_props)
        ax[0].plot(self.lc.times.jd - min_jd_int, model, 'r', lw='3')

        for individual_model in individual_models:
            ax[0].plot(self.lc.times.jd - min_jd_int, individual_model, 'b')<commit_msg>Speeding up corner plot<commit_after>
from __future__ import absolute_import, print_function

from .fitting import spotted_transit_model, spotted_transit_model_individuals
from .storage import read_results_archive
from .lightcurve import TransitLightCurve

import matplotlib.pyplot as plt
from corner import corner


class MCMCResults(object):
    def __init__(self, archive_path):

        results = read_results_archive(archive_path)
        self.lnprob, self.best_params, self.chains, lc_matrix = results

        self.lc = TransitLightCurve(times=lc_matrix[0, :],
                                    fluxes=lc_matrix[1, :],
                                    errors=lc_matrix[2, :])

    def plot_lnprob(self):
        plt.figure()
        plt.title('$\log \,p$')
        plt.plot(self.lnprob)
        plt.xlabel('Step')
        plt.ylabel('$\log \,p$')

    def plot_corner(self, skip_every=100):
        labels = ['depth']
        for i in range(self.chains.shape[0]):
            labels.extend(['$a_{0}$'.format(i), '$t_{{0,{0}}}$'.format(i),
                           '$\sigma_{0}$'.format(i)])
        corner(self.chains[::skip_every, :], labels=labels)

    def plot_max_lnp_lc(self, transit_params):
        model = spotted_transit_model(self.best_params, self.lc.times.jd,
                                      transit_params)
        individual_models = spotted_transit_model_individuals(self.best_params,
                                                              self.lc.times.jd,
                                                              transit_params)

        errorbar_props = dict(fmt='.', color='k', capsize=0, ecolor='gray')

        fig, ax = plt.subplots(2, 1, figsize=(8, 10), sharex=True)

        min_jd_int = int(self.lc.times.jd.min())
        ax[0].errorbar(self.lc.times.jd - min_jd_int, self.lc.fluxes,
                       self.lc.errors, **errorbar_props)
        ax[0].plot(self.lc.times.jd - min_jd_int, model, 'r', lw='3')

        for individual_model in individual_models:
            ax[0].plot(self.lc.times.jd - min_jd_int, individual_model, 'b')
{'fraction_non_alphanumeric': 0.12332375478927203, 'fraction_numerical': 0.009339080459770116, 'mean_word_length': 2.080383480825959, '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': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1164335', 'n_tokens_mistral': 1302, 'n_tokens_neox': 1247, 'n_words': 220}