<commit_before>import ROOT
import numpy as np

from threeML.minimizer.minimization import LocalMinimizer, FitFailed, CannotComputeCovariance
from threeML.io.dict_with_pretty_print import DictWithPrettyPrint

# These are the status returned by Minuit
#     status = 1    : Covariance was made pos defined
#     status = 2    : Hesse is invalid
#     status = 3    : Edm is above max
#     status = 4    : Reached call limit
#     status = 5    : Any other failure
_status_translation = {1: 'Covariance was made pos. defined',
                       2: 'Hesse is invalid',
                       3: 'Edm is above maximum',
                       4: 'Reached call limit',
                       5: 'Unknown failure'}

# Status for HESSE
# status += 100*hesseStatus where hesse status is:
# status = 1 : hesse failed
# status = 2 : matrix inversion failed
# status = 3 : matrix is not pos defined
_hesse_status_translation = {100: 'HESSE failed',
                             200: 'Covariance matrix inversion failed',
                             300: 'Covariance matrix is not positive defined'}


class FuncWrapper(ROOT.TPyMultiGenFunction):

    def __init__(self, function, dimensions):

        ROOT.TPyMultiGenFunction.__init__(self, self)
        self.function = function
        self.dimensions = int(dimensions)

    def NDim(self):
        return self.dimensions

    def DoEval(self, args):

        new_args = map(lambda i:args[i],range(self.dimensions))

        return self.function(*new_args)


class ROOTMinimizer(LocalMinimizer):

    valid_setup_keys = ('ftol', 'max_function_calls', 'strategy')

    def __init__(self, function, parameters, verbosity=0):

        super(ROOTMinimizer, self).__init__(function, parameters, verbosity)

    def _setup(self, user_setup_dict):

        # Defaults

        setup_dict = {'ftol': 0.01,
                      'max_function_calls': 100000,
                      'strategy': 1}

        # Update defaults if needed
        if user_setup_dict is not None:

            for key in user_setup_dict:

                setup_dict[key] = user_setup_dict[key]<commit_msg>Reduced the tolerance to improve speed<commit_after>import ROOT
import numpy as np

from threeML.minimizer.minimization import LocalMinimizer, FitFailed, CannotComputeCovariance
from threeML.io.dict_with_pretty_print import DictWithPrettyPrint

# These are the status returned by Minuit
#     status = 1    : Covariance was made pos defined
#     status = 2    : Hesse is invalid
#     status = 3    : Edm is above max
#     status = 4    : Reached call limit
#     status = 5    : Any other failure
_status_translation = {1: 'Covariance was made pos. defined',
                       2: 'Hesse is invalid',
                       3: 'Edm is above maximum',
                       4: 'Reached call limit',
                       5: 'Unknown failure'}

# Status for HESSE
# status += 100*hesseStatus where hesse status is:
# status = 1 : hesse failed
# status = 2 : matrix inversion failed
# status = 3 : matrix is not pos defined
_hesse_status_translation = {100: 'HESSE failed',
                             200: 'Covariance matrix inversion failed',
                             300: 'Covariance matrix is not positive defined'}


class FuncWrapper(ROOT.TPyMultiGenFunction):

    def __init__(self, function, dimensions):

        ROOT.TPyMultiGenFunction.__init__(self, self)
        self.function = function
        self.dimensions = int(dimensions)

    def NDim(self):
        return self.dimensions

    def DoEval(self, args):

        new_args = map(lambda i:args[i],range(self.dimensions))

        return self.function(*new_args)


class ROOTMinimizer(LocalMinimizer):

    valid_setup_keys = ('ftol', 'max_function_calls', 'strategy')

    def __init__(self, function, parameters, verbosity=0):

        super(ROOTMinimizer, self).__init__(function, parameters, verbosity)

    def _setup(self, user_setup_dict):

        # Defaults

        setup_dict = {'ftol': 1.0,
                      'max_function_calls': 100000,
                      'strategy': 1}

        # Update defaults if needed
        if user_setup_dict is not None:

            for key in user_setup_dict:

                setup_dict[key] = user_setup_dict[key]
{'fraction_non_alphanumeric': 0.0825515947467167, 'fraction_numerical': 0.016651031894934335, 'mean_word_length': 2.4065495207667733, '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': '803504', 'n_tokens_mistral': 1301, 'n_tokens_neox': 1181, 'n_words': 364}