<commit_before># -*- coding: utf-8 -*-
"""
Created on Nov 17 10:53 2017
@author(s): <NAME>

Contains a basic class with the functions, which spotpy needs to work properly.
Is separated to make the model template more readable
"""
import datetime
import numpy as np
import spotpy


class SpotpyInterface:
    def __init__(self):
        self.params = None
        self.setparameters = None
        self.run_model = None
        self.obs_discharge = None
        self.begin_calibration = None
        self.end_calibration = None

    def simulation(self, vector):
        """
        SpotPy expects a method simulation. This methods calls setparameters
        and runmodels, so SpotPy is satisfied.
        """
        param_dict = dict((pp.name, v) for pp, v in zip(self.params, vector))
        self.setparameters(param_dict)

        sim_discharge = self.run_model()
        return np.array(sim_discharge)

    def evaluation(self):
        """
        For Spotpy. Creates a numpy array from the evaluation timeseries.
        """
        return np.array(
            self.obs_discharge[self.begin_calibration:self.end_calibration])

    def parameters(self):
        """
        For Spotpy. Tells Spotpy the parameter names and ranges.
        """
        return spotpy.parameter.generate(self.params)<commit_msg>Corrected return value of simulation when run_model times out<commit_after># -*- coding: utf-8 -*-
"""
Created on Nov 17 10:53 2017
@author(s): <NAME>

Contains a basic class with the functions, which spotpy needs to work properly.
Is separated to make the model template more readable
"""
import datetime
import numpy as np
import spotpy


class SpotpyInterface:
    def __init__(self):
        self.params = None
        self.setparameters = None
        self.run_model = None
        self.obs_discharge = None
        self.begin_calibration = None
        self.end_calibration = None
        self.end_validation = None

    def simulation(self, vector):
        """
        SpotPy expects a method simulation. This methods calls setparameters
        and runmodels, so SpotPy is satisfied.
        """
        param_dict = dict((pp.name, v) for pp, v in zip(self.params, vector))
        self.setparameters(param_dict)
        try:
            sim_discharge = self.run_model()
        except KeyboardInterrupt:
            sim_discharge = np.array(self.obs_discharge[
                            self.begin_calibration:self.end_validation])*np.nan
        return np.array(sim_discharge)

    def evaluation(self):
        """
        For Spotpy. Creates a numpy array from the evaluation timeseries.
        """
        return np.array(
            self.obs_discharge[self.begin_calibration:self.end_calibration])

    def parameters(self):
        """
        For Spotpy. Tells Spotpy the parameter names and ranges.
        """
        return spotpy.parameter.generate(self.params)
{'fraction_non_alphanumeric': 0.08407994486560992, 'fraction_numerical': 0.007580978635423846, 'mean_word_length': 2.4477434679334915, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1206003', 'n_tokens_mistral': 807, 'n_tokens_neox': 775, 'n_words': 249}