diff --git a/spotpy/examples/tutorial_padds_hymod.py b/spotpy/examples/tutorial_padds_hymod.py index 76250f52..5de56360 100644 --- a/spotpy/examples/tutorial_padds_hymod.py +++ b/spotpy/examples/tutorial_padds_hymod.py @@ -136,7 +136,7 @@ def plot_parameter_histogram(ax, results, parameter): ax11.plot(q95,color='dimgrey',linestyle='solid') ax11.fill_between(np.arange(0,len(q5),1),list(q5),list(q95),facecolor='dimgrey',zorder=0, linewidth=0,label='parameter uncertainty') - ax11.plot(spot_setup.evaluation(),'r.',label='data')ยด + ax11.plot(spot_setup.evaluation(),'r.',label='data') ax11.set_ylim(-50,450) ax11.set_xlim(0,729) ax11.legend() diff --git a/tests/test_algorithms.py b/tests/test_algorithms.py index e845bb31..3a565496 100644 --- a/tests/test_algorithms.py +++ b/tests/test_algorithms.py @@ -14,8 +14,10 @@ import spotpy #from spotpy.examples.tutorial_padds import padds_spot_setup from spotpy.examples.spot_setup_rosenbrock import spot_setup -#from spotpy.describe import describe +from spotpy.examples.spot_setup_hymod_python import spot_setup as spot_setup_hymod +from spotpy.describe import describe import os +import numpy as np from spotpy.likelihoods import gaussianLikelihoodMeasErrorOut as GausianLike @@ -28,7 +30,7 @@ def multi_obj_func(self, evaluation, simulation, params=None): like1 = abs(spotpy.objectivefunctions.bias(evaluation, simulation)) like2 = spotpy.objectivefunctions.rmse(evaluation, simulation) like3 = spotpy.objectivefunctions.rsquared(evaluation, simulation)*-1 - return [like2, like3] + return np.array([like1, like2, like3]) def setUp(self): # How many digits to match in case of floating point answers @@ -122,17 +124,16 @@ def test_fast(self): results = sampler.getdata() self.assertEqual(len(results), self.rep) #Si values should be returned -# def test_padds(self): -# sampler=spotpy.algorithms.padds(padds_spot_setup(),parallel=self.parallel, dbname='Rosen', dbformat=self.dbformat, sim_timeout=self.timeout) -# sampler.sample(self.rep) -# results = sampler.getdata() -# self.assertEqual(len(results)+5, self.rep) #Si values should be returned + def test_padds(self): + sampler=spotpy.algorithms.padds(spot_setup_hymod(self.multi_obj_func),parallel=self.parallel, dbname='Rosen', dbformat=self.dbformat, sim_timeout=self.timeout) + sampler.sample(int(self.rep*0.5), metric='ones') + results = sampler.getdata() + self.assertEqual(len(results)+5, int(self.rep*0.5)) def test_nsgaii(self): - generations=40 - n_pop = 20 - skip_duplicates = True - sampler=spotpy.algorithms.NSGAII(spot_setup(self.multi_obj_func),parallel=self.parallel, dbname='Rosen', dbformat=self.dbformat, sim_timeout=self.timeout) + generations=20 + n_pop = 10 + sampler=spotpy.algorithms.NSGAII(spot_setup_hymod(self.multi_obj_func),parallel=self.parallel, dbname='Rosen', dbformat=self.dbformat, sim_timeout=self.timeout) sampler.sample(generations, n_obj= 3, n_pop = n_pop) results = sampler.getdata() self.assertLessEqual(len(results), generations*n_pop)