Skip to content

Commit

Permalink
Merge branch 'master' into pr/246
Browse files Browse the repository at this point in the history
  • Loading branch information
thouska authored Oct 9, 2020
2 parents f90a388 + a6e921d commit c9b5df2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion spotpy/examples/tutorial_padds_hymod.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
23 changes: 12 additions & 11 deletions tests/test_algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit c9b5df2

Please sign in to comment.