<commit_before># -*- coding: utf-8 -*-
import logging
import numpy as np
from scipy.integrate import simps
from scipy.interpolate import interp1d
from scipy.ndimage.filters import gaussian_filter

from .helpers import get_smoothed_bins, get_grid_bins, get_latex_table_frame
from .kde import MegKDE


class Analysis(object):

    summaries = ["max", "mean", "cumulative", "max_symmetric", "max_shortest", "max_central"]

    def __init__(self, parent):
        self.parent = parent
        self._logger = logging.getLogger("chainconsumer")

        self._summaries = {
            "max": self.get_parameter_summary_max,
            "mean": self.get_parameter_summary_mean,
            "cumulative": self.get_parameter_summary_cumulative,
            "max_symmetric": self.get_paramater_summary_max_symmetric,
            "max_shortest": self.get_parameter_summary_max_shortest,
            "max_central": self.get_parameter_summary_max_central
        }

    def get_latex_table(self, parameters=None, transpose=False, caption=None,
                        label="tab:model_params", hlines=True, blank_fill="--", filename=None):  # pragma: no cover
        """ Generates a LaTeX table from parameter summaries.

        Parameters
        ----------
        parameters : list[str], optional
            A list of what parameters to include in the table. By default, includes all parameters
        transpose : bool, optional
            Defaults to False, which gives each column as a parameter, each chain (framework)
            as a row. You can swap it so that you have a parameter each row and a framework
            each column by setting this to True
        caption : str, optional
            If you want to generate a caption for the table through Python, use this.
            Defaults to an empty string
        label : str, optional
            If you want to generate a label for the table through Python, use this.
            Defaults to an empty string
        hlines : bool, optional
            Inserts ``\\hline`` before and after the header, and at the end of table.
        blank_fill : str, optional
            If a framework does not have a particular parameter, will fill that cell of
            the table with this string.
        filename : str, optional
            The file to save the output string to

        Returns
        -------
        str
            the LaTeX table.
        """
        if parameters is None:
            parameters = self.parent._all_parameters
        for p in parameters:<commit_msg>Allowing get_latex_table to accept an input number of parameters<commit_after># -*- coding: utf-8 -*-
import logging
import numpy as np
from scipy.integrate import simps
from scipy.interpolate import interp1d
from scipy.ndimage.filters import gaussian_filter

from .helpers import get_smoothed_bins, get_grid_bins, get_latex_table_frame
from .kde import MegKDE


class Analysis(object):

    summaries = ["max", "mean", "cumulative", "max_symmetric", "max_shortest", "max_central"]

    def __init__(self, parent):
        self.parent = parent
        self._logger = logging.getLogger("chainconsumer")

        self._summaries = {
            "max": self.get_parameter_summary_max,
            "mean": self.get_parameter_summary_mean,
            "cumulative": self.get_parameter_summary_cumulative,
            "max_symmetric": self.get_paramater_summary_max_symmetric,
            "max_shortest": self.get_parameter_summary_max_shortest,
            "max_central": self.get_parameter_summary_max_central
        }

    def get_latex_table(self, parameters=None, transpose=False, caption=None,
                        label="tab:model_params", hlines=True, blank_fill="--", filename=None):  # pragma: no cover
        """ Generates a LaTeX table from parameter summaries.

        Parameters
        ----------
        parameters : list[str], int optional
            A list of what parameters to include in the table. By default, includes all parameters
        transpose : bool, optional
            Defaults to False, which gives each column as a parameter, each chain (framework)
            as a row. You can swap it so that you have a parameter each row and a framework
            each column by setting this to True
        caption : str, optional
            If you want to generate a caption for the table through Python, use this.
            Defaults to an empty string
        label : str, optional
            If you want to generate a label for the table through Python, use this.
            Defaults to an empty string
        hlines : bool, optional
            Inserts ``\\hline`` before and after the header, and at the end of table.
        blank_fill : str, optional
            If a framework does not have a particular parameter, will fill that cell of
            the table with this string.
        filename : str, optional
            The file to save the output string to

        Returns
        -------
        str
            the LaTeX table.
        """
        if parameters is None:
            parameters = self.parent._all_parameters
        elif isinstance(parameters, int):
            parameters = self.parent._all_parameters[:parameters]
        for p in parameters:
{'fraction_non_alphanumeric': 0.07122452866120739, 'fraction_numerical': 0.0007617596648257475, 'mean_word_length': 2.3494897959183674, 'pattern_counts': {'":': 12, '<': 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': '6686087', 'n_tokens_mistral': 1371, 'n_tokens_neox': 1318, 'n_words': 507}