<commit_before>import matplotlib.pyplot as plt
from matplotlib.ticker import MaxNLocator
import numpy as np

from threeML.io.plotting.step_plot import step_plot
from threeML.config.config import threeML_config

from threeML.exceptions.custom_exceptions import custom_warnings

class ResidualPlot(object):

    def __init__(self,**kwargs):
        """

        :param show_residuals: to show the residuals
        :param ratio_residuals: to use ratios instead of sigma
        """


        self._ratio_residuals = False
        self._show_residuals = True


        if 'show_residuals' in kwargs:

            self._show_residuals = bool(kwargs.pop('show_residuals'))

        if 'ratio_residuals' in kwargs:
            self._ratio_residuals = bool(kwargs.pop('ratio_residuals'))


        # this lets you overplot other fits

        if 'model_subplot' in kwargs:

            model_subplot = kwargs.pop('model_subplot')

            # turn on or off residuals

            if self._show_residuals:

                assert type(model_subplot) == list, 'you must supply a list of axes to plot to residual'

                assert len(
                    model_subplot) == 2, 'you have requested to overplot a model with residuals, but only provided one axis to plot'

                self._data_axis, self._residual_axis = model_subplot

            else:

                try:

                    self._data_axis = model_subplot

                    self._fig = self._data_axis.get_figure()

                except(AttributeError):

                    assert len(model_subplot) == 1, 'The axes you have supplied is invalid'

                    # the user supplied a list of axes

                    self._data_axis = model_subplot[0]

                    self._fig = self._data_axis.get_figure()





<commit_msg>added some checks<commit_after>import matplotlib.pyplot as plt
from matplotlib.ticker import MaxNLocator
import numpy as np

from threeML.io.plotting.step_plot import step_plot
from threeML.config.config import threeML_config

from threeML.exceptions.custom_exceptions import custom_warnings

class ResidualPlot(object):

    def __init__(self,**kwargs):
        """

        :param show_residuals: to show the residuals
        :param ratio_residuals: to use ratios instead of sigma
        """


        self._ratio_residuals = False
        self._show_residuals = True


        if 'show_residuals' in kwargs:

            self._show_residuals = bool(kwargs.pop('show_residuals'))

        if 'ratio_residuals' in kwargs:
            self._ratio_residuals = bool(kwargs.pop('ratio_residuals'))


        # this lets you overplot other fits

        if 'model_subplot' in kwargs:

            model_subplot = kwargs.pop('model_subplot')

            # turn on or off residuals

            if self._show_residuals:

                assert type(model_subplot) == list, 'you must supply a list of axes to plot to residual'

                assert len(
                    model_subplot) == 2, 'you have requested to overplot a model with residuals, but only provided one axis to plot'

                self._data_axis, self._residual_axis = model_subplot

            else:

                try:

                    self._data_axis = model_subplot

                    self._fig = self._data_axis.get_figure()

                except(AttributeError):

                    # the user supplied a list of axes

                    self._data_axis = model_subplot[0]

            self._fig = self._data_axis.get_figure()






{'fraction_non_alphanumeric': 0.06689246401354784, 'fraction_numerical': 0.0014112334180073384, 'mean_word_length': 2.063094209161625, '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': '4428992', 'n_tokens_mistral': 1042, 'n_tokens_neox': 944, 'n_words': 276}