Skip to content

Commit

Permalink
support for python 3.5 and 3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
thouska committed May 31, 2017
1 parent 882c64a commit 3cdc1a2
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 39 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ __pycache__/
*.yml
*.csv
*.out
*.in
docs/*

# Distribution / packaging
Expand Down Expand Up @@ -101,4 +102,4 @@ ENV/
# LiClipse project settings
.pydevproject
.project
.settings/
.settings/
2 changes: 1 addition & 1 deletion spotpy/algorithms/fast.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def sample(self, repetitions):
#param_generator = iter(Matrix)
firstcall = True
param_generator = (
(rep, Matrix[rep]) for rep in xrange(len(Matrix)))
(rep, Matrix[rep]) for rep in range(len(Matrix)))
for rep, randompar, simulations in self.repeat(param_generator):
# Calculate the objective function
like = self.objectivefunction(
Expand Down
2 changes: 1 addition & 1 deletion spotpy/algorithms/lhs.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def sample(self, repetitions):
# param_generator = iter(matrx)
firstcall = True
param_generator = ((rep, matrx[rep])
for rep in xrange(int(repetitions) - 1))
for rep in range(int(repetitions) - 1))
for rep, randompar, simulations in self.repeat(param_generator):
# Calculate the objective function
like = self.objectivefunction(
Expand Down
4 changes: 2 additions & 2 deletions spotpy/algorithms/mcmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def sample(self, repetitions,nChains=1):

print('Inititalize ',self.nChains, ' chain(s)...')
self.iter=0
param_generator = ((curChain,self.parameter()['random']) for curChain in xrange(int(self.nChains)))
param_generator = ((curChain,self.parameter()['random']) for curChain in range(int(self.nChains)))
for curChain,par,sim in self.repeat(param_generator):

like = self.objectivefunction(
Expand All @@ -132,7 +132,7 @@ def sample(self, repetitions,nChains=1):
print('Beginn of Random Walk')
#Walf through chains
while self.iter <= self.repetitions - self.burnIn:
param_generator = ((curChain,self.get_new_proposal_vector(self.bestpar[curChain])) for curChain in xrange(int(self.nChains)))
param_generator = ((curChain,self.get_new_proposal_vector(self.bestpar[curChain])) for curChain in range(int(self.nChains)))
for cChain,par,sim in self.repeat(param_generator):

like = self.objectivefunction(
Expand Down
6 changes: 3 additions & 3 deletions spotpy/algorithms/sceua.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def simulate(self, id_params_tuple):
likes = []
sims = []
pars = []
for loop in xrange(self.nspl):
for loop in range(self.nspl):
# Select simplex by sampling the complex according to a linear
# probability distribution
lcs = np.array([0] * self.nps)
Expand Down Expand Up @@ -202,7 +202,7 @@ def sample(self, repetitions, ngs=20, kstop=100, pcento=0.0000001, peps=0.000000

# Burn in
firstcall = True
param_generator = ((rep, x[rep]) for rep in xrange(int(npt)))
param_generator = ((rep, x[rep]) for rep in range(int(npt)))
for rep, randompar, simulations in self.repeat(param_generator):
# Calculate the objective function
like = self.objectivefunction(
Expand Down Expand Up @@ -279,7 +279,7 @@ def sample(self, repetitions, ngs=20, kstop=100, pcento=0.0000001, peps=0.000000
sce_vars = [self.npg, self.nopt, self.ngs, self.nspl,
self.nps, self.bl, self.bu, self.status]
param_generator = ((rep, x, xf, icall, cx, cf, sce_vars)
for rep in xrange(int(self.ngs)))
for rep in range(int(self.ngs)))
for igs, likes, pars, sims, cx, cf, k1, k2 in self.repeat(param_generator):
icall += len(likes)
x[k2, :] = cx[k1, :]
Expand Down
2 changes: 1 addition & 1 deletion spotpy/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def _make_header(self, parnames):
self.header.append('chain')

def _tuple_2_xrange(self, t):
return (xrange(1, x + 1) for x in t)
return (range(1, x + 1) for x in t)


class ram(database):
Expand Down
4 changes: 2 additions & 2 deletions spotpy/examples/3dplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
from spotpy.examples.spot_setup_ackley import spot_setup

Z = np.zeros(X.shape)
for i in xrange(X.shape[0]):
for j in xrange(X.shape[1]):
for i in range(X.shape[0]):
for j in range(X.shape[1]):
sim=spot_setup().simulation([X[i,j],Y[i,j]])
like=spotpy.objectivefunctions.rmse(sim,[0])
Z[i,j] = like
Expand Down
2 changes: 1 addition & 1 deletion spotpy/examples/tutorial_Parameterlist_iterator.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def parameters(self):

def simulation(self,vector):
x=np.array(vector)
for i in xrange(self.slow):
for i in range(self.slow):
s = np.sin(i)
simulations= [sum(100.0*(x[1:] - x[:-1]**2.0)**2.0 + (1 - x[:-1])**2.0)]
return simulations
Expand Down
2 changes: 1 addition & 1 deletion spotpy/examples/tutorial_ownDatabase.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def parameters(self):

def simulation(self,vector):
x=np.array(vector)
for i in xrange(self.slow):
for i in range(self.slow):
s = np.sin(i)
simulations= [sum(100.0*(x[1:] - x[:-1]**2.0)**2.0 + (1 - x[:-1])**2.0)]
return simulations
Expand Down
1 change: 0 additions & 1 deletion spotpy/tools/__init__.py

This file was deleted.

25 changes: 0 additions & 25 deletions spotpy/tools/progressbar.py

This file was deleted.

0 comments on commit 3cdc1a2

Please sign in to comment.