Ejemplo n.º 1
0
    def setUpClass(self):
        np.random.seed(42)
        self.rep = 300
        self.parallel = "seq"
        self.dbformat = "ram"
        self.timeout = 5
        self.fig_name = 'test_output.png'

        sampler = spotpy.algorithms.mc(rosenbrock_setup(),
                                       sim_timeout=self.timeout)
        sampler.sample(self.rep)
        self.results = sampler.getdata()

        sampler = spotpy.algorithms.mc(griewank_setup(),
                                       sim_timeout=self.timeout)
        sampler.sample(self.rep)
        self.griewank_results = sampler.getdata()
        if sys.version_info >= (3, 6):  # FAST is only fully operational under
            #Python 3
            sampler = spotpy.algorithms.fast(rosenbrock_setup(),
                                             sim_timeout=self.timeout)
            sampler.sample(self.rep)
            self.sens_results = sampler.getdata()
            #Hymod resuts are empty with Python <3.6
            sampler = spotpy.algorithms.dream(hymod_setup(GausianLike),
                                              sim_timeout=self.timeout)
            self.r_hat = sampler.sample(self.rep)
            self.hymod_results = sampler.getdata()
Ejemplo n.º 2
0
    def test_plot_bestmodelrun(self):
        spotpy.analyser.plot_bestmodelrun(self.griewank_results,
                                          griewank_setup().evaluation(),
                                          fig_name=self.fig_name)

        # approximately 8855 KB is the size of an empty matplotlib.pyplot.plot, so
        # we expecting a plot with some content without testing the structure of the plot, just
        # the size
        self.assertGreaterEqual(os.path.getsize(self.fig_name), 8855)
        os.remove(self.fig_name)
Ejemplo n.º 3
0
 def test_plot_parametertrace_algorithms(self):
     spotpy.analyser.plot_parametertrace_algorithms(
         [self.griewank_results], ["test_plot_parametertrace_algorithms"],
         spot_setup=griewank_setup(),
         fig_name=self.fig_name)
     # approximately 8855 KB is the size of an empty matplotlib.pyplot.plot, so
     # we expecting a plot with some content without testing the structure of the plot, just
     # the size
     self.assertGreaterEqual(os.path.getsize(self.fig_name), 8855)
     os.remove(self.fig_name)