def test_plot_bestmodelruns(self): if sys.version_info >= (3, 6): spotpy.analyser.plot_bestmodelruns( [self.hymod_results[0:10], self.hymod_results[10:20]], hymod_setup().evaluation(), dates=range(1, 1 + len(hymod_setup().evaluation())), algorithms=["test", "test2"], 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)
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()
def test_plot_posterior(self): if sys.version_info >= (3, 6): spotpy.analyser.plot_posterior(self.hymod_results, hymod_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)
def test_plot_allmodelruns(self): if sys.version_info >= (3, 6): modelruns = [] for run in self.hymod_results: on_run = [] for i in run: on_run.append(i) on_run = np.array(on_run)[:-7] modelruns.append(on_run.tolist()) spotpy.analyser.plot_allmodelruns( modelruns, hymod_setup().evaluation(), dates=range(1, len(hymod_setup().evaluation()) + 1), 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)
def test_plot_parameter_uncertainty(self): if sys.version_info >= (3, 6): posterior = spotpy.analyser.get_posterior(self.hymod_results, percentage=10) self.assertAlmostEqual(len(posterior), self.rep * 0.1, 2) self.assertEqual(type(posterior), type(np.array([]))) spotpy.analyser.plot_parameter_uncertainty( posterior, hymod_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)