Skip to content

Commit 5b094bf

Browse files
authored
Merge pull request #334 from Zeitsperre/typo-adjustments
Typo adjustments, black formatting, drop Python 3.9, support Python 3.13
2 parents 47dd43f + 459e293 commit 5b094bf

45 files changed

Lines changed: 419 additions & 389 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/main.yml

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,37 +18,40 @@ env:
1818

1919
jobs:
2020
source_check:
21-
name: source check
21+
name: Linting (Python ${{ matrix.python-version }})
2222
runs-on: ubuntu-latest
2323
strategy:
2424
fail-fast: false
25+
matrix:
26+
python-version: [ '3.12' ]
2527

2628
steps:
2729
- uses: actions/checkout@v4
2830

29-
- name: Set up Python 3.12
31+
- name: Set up Python ${{ matrix.python-version }}
3032
uses: actions/setup-python@v5
3133
with:
32-
python-version: 3.12
34+
python-version: ${{ matrix.python-version }}
3335

3436
- name: Install dependencies
3537
run: |
3638
python -m pip install --upgrade pip
37-
pip install black 'isort[colors]<6'
38-
pip install --editable .
39+
python -m pip install black 'isort[colors]<6'
40+
python -m pip install --editable .
3941
4042
- name: isort check
4143
run: |
44+
python -m black --check --diff --color .
4245
python -m isort --check --diff --color .
4346
4447
build_sdist:
45-
name: sdist on ${{ matrix.os }} with py ${{ matrix.python-version }}
48+
name: sdist on ${{ matrix.os }} with Python ${{ matrix.python-version }}
4649
runs-on: ${{ matrix.os }}
4750
strategy:
4851
fail-fast: false
4952
matrix:
50-
os: [ubuntu-latest, windows-latest, macos-latest]
51-
python-version: ['3.12']
53+
os: [ 'ubuntu-latest', 'windows-latest', 'macos-latest' ]
54+
python-version: [ '3.10', '3.13' ]
5255

5356
steps:
5457
- uses: actions/checkout@v4
@@ -63,28 +66,36 @@ jobs:
6366
- name: Install dependencies
6467
run: |
6568
python -m pip install --upgrade pip
66-
pip install build coveralls>=3.0.0
67-
pip install --editable .[test]
69+
python -m pip install build pytest-cov
70+
python -m pip install --editable .[test]
6871
6972
- name: Run tests
70-
env:
71-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7273
run: |
7374
python -m pytest --cov spotpy --cov-report term-missing -v tests/
75+
76+
- name: Upload coverage to Coveralls
77+
if: matrix.python-version != '3.13'
78+
run: |
79+
python -m pip install coveralls
7480
python -m coveralls --service=github
81+
env:
82+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7583

7684
- name: Build sdist
85+
if: matrix.python-version == '3.13'
7786
run: |
7887
python -m build
7988
8089
- uses: actions/upload-artifact@v4
81-
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12'
90+
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.13'
8291
with:
8392
name: dist-sdist
8493
path: dist/
8594

8695
upload_to_pypi:
87-
needs: [build_sdist]
96+
name: Upload to PyPI/Test PyPI
97+
needs:
98+
- build_sdist
8899
runs-on: ubuntu-latest
89100
steps:
90101
- name: Download all the dists

README.md

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,13 @@ A Statistical Parameter Optimization Tool for Python
1616
[license-image]: https://img.shields.io/badge/license-MIT-blue.png
1717
[license-link]: http://opensource.org/licenses/MIT
1818

19-
20-
2119
Purpose
22-
=================
23-
20+
=======
2421

2522
https://github.com/user-attachments/assets/4df71cb2-dcf9-4a24-bb78-6e4e1c43356a
2623

27-
2824
SPOTPY is a Python framework that enables the use of Computational optimization techniques for calibration, uncertainty
29-
and sensitivity analysis techniques of almost every (environmental-) model. The package is puplished in the open source journal PLoS One:
25+
and sensitivity analysis techniques of almost every (environmental-) model. The package is published in the open source journal PLoS One:
3026

3127
Houska, T., Kraft, P., Chamorro-Chavez, A. and Breuer, L.: SPOTting Model Parameters Using a Ready-Made Python Package, PLoS ONE,
3228
10(12), e0145180, doi:[10.1371/journal.pone.0145180](http://journals.plos.org/plosone/article?id=10.1371%2Fjournal.pone.0145180 "SPOTting Model Parameters Using a Ready-Made Python Package"), 2015
@@ -39,10 +35,8 @@ algorithms of almost any model, without the need of complex codes::
3935
results = sampler.getdata() # Load the results
4036
spotpy.analyser.plot_parametertrace(results) # Show the results
4137

42-
43-
4438
Features
45-
=================
39+
========
4640

4741
Complex algorithms bring complex tasks to link them with a model.
4842
We want to make this task as easy as possible.
@@ -65,7 +59,7 @@ Some features you can use with the SPOTPY package are:
6559
* Artificial Bee Colony (`ABC`)
6660
* Fitness Scaled Chaotic Artificial Bee Colony (`FSCABC`)
6761
* Dynamically Dimensioned Search algorithm (`DDS`)
68-
* Pareto Archived - Dynamicallly Dimensioned Search algorithm (`PA-DDS`)
62+
* Pareto Archived - Dynamically Dimensioned Search algorithm (`PA-DDS`)
6963
* Fast and Elitist Multiobjective Genetic Algorithm (`NSGA-II`)
7064

7165
* Wide range of objective functions (also known as loss function, fitness function or energy function) to validate the sampled results. Available functions are
@@ -84,7 +78,7 @@ Some features you can use with the SPOTPY package are:
8478
* Agreement Index (`AI`)
8579
* Covariance, Decomposed MSE (`dMSE`)
8680
* Kling-Gupta Efficiency (`KGE`)
87-
* Non parametric Kling-Gupta Efficiency (`KGE_non_parametric`)
81+
* Non-parametric Kling-Gupta Efficiency (`KGE_non_parametric`)
8882

8983
* Wide range of hydrological signatures functions to validate the sampled results:
9084

@@ -102,12 +96,12 @@ Some features you can use with the SPOTPY package are:
10296

10397
* Uniform
10498
* Normal
105-
* logNormal
106-
* Chisquare
99+
* log-normal
100+
* Chi-Square
107101
* Exponential
108102
* Gamma
109103
* Wald
110-
* Weilbull
104+
* Weibull
111105

112106
* Wide range to adapt algorithms to perform uncertainty-, sensitivity analysis or calibration
113107
of a model.
@@ -137,7 +131,7 @@ Some features you can use with the SPOTPY package are:
137131

138132

139133
Install
140-
=================
134+
=======
141135

142136
Classical Python options exist to install SPOTPY:
143137

@@ -157,7 +151,7 @@ From [Source](https://pypi.python.org/pypi/spotpy):
157151

158152

159153
Support
160-
=================
154+
=======
161155

162156
* Documentation: https://spotpy.readthedocs.io/en/latest/
163157

@@ -171,12 +165,12 @@ Support
171165

172166

173167
Getting started
174-
=================
168+
===============
175169
Have a look at https://github.com/thouska/spotpy/tree/master/spotpy/examples and https://spotpy.readthedocs.io/en/latest/getting_started/
176170

177171

178172
Contributing
179-
=================
173+
============
180174
Patches/enhancements/new algorithms and any other contributions to this package are very welcome!
181175

182176
1. Fork it ( http://github.com/thouska/spotpy/fork )
@@ -188,5 +182,5 @@ Patches/enhancements/new algorithms and any other contributions to this package
188182
7. Create new Pull Request
189183

190184
Papers citing SPOTPY
191-
=====================
185+
====================
192186
See [Google Scholar](https://scholar.google.de/scholar?cites=17155001516727704728&as_sdt=2005&sciodt=0,5&hl=de) for a continuously updated list.

pyproject.toml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ requires = [
66
build-backend = "setuptools.build_meta"
77

88
[project]
9-
requires-python = ">=3.9"
9+
requires-python = ">=3.10"
1010
name = "spotpy"
1111
description = "A Statistical Parameter Optimization Tool."
1212
authors = [
@@ -55,8 +55,10 @@ classifiers = [
5555
"Programming Language :: Python",
5656
"Programming Language :: Python :: 3",
5757
"Programming Language :: Python :: 3 :: Only",
58+
"Programming Language :: Python :: 3.10",
59+
"Programming Language :: Python :: 3.11",
5860
"Programming Language :: Python :: 3.12",
59-
61+
"Programming Language :: Python :: 3.13",
6062
"Topic :: Scientific/Engineering",
6163
"Topic :: Scientific/Engineering :: Hydrology",
6264
"Topic :: Scientific/Engineering :: Mathematics",
@@ -106,7 +108,11 @@ multi_line_output = 3
106108
[tool.black]
107109
exclude = "_version.py"
108110
target-version = [
111+
"py39",
112+
"py310",
113+
"py311",
109114
"py312",
115+
"py313",
110116
]
111117

112118
[tool.coverage]

src/spotpy/algorithms/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
77
:author: Tobias Houska
88
9-
:paper: Houska, T., Kraft, P., Chamorro-Chavez, A. and Breuer, L.:
10-
SPOTting Model Parameters Using a Ready-Made Python Package,
9+
:paper: Houska, T., Kraft, P., Chamorro-Chavez, A. and Breuer, L.:
10+
SPOTting Model Parameters Using a Ready-Made Python Package,
1111
PLoS ONE, 10(12), e0145180, doi:10.1371/journal.pone.0145180, 2015.
1212
1313
Imports the different algorithms from this package.

src/spotpy/algorithms/_algorithm.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
66
This file holds the standards for every algorithm.
77
"""
8+
89
import random
910
import threading
1011
import time
@@ -516,9 +517,9 @@ def simulate(self, id_params_tuple):
516517
can mix up the ordering of runs
517518
"""
518519
id, params = id_params_tuple
519-
self.all_params[
520-
self.non_constant_positions
521-
] = params # TODO: List parameters are not updated if not accepted for the algorithm, we may have to warn/error if list is given
520+
self.all_params[self.non_constant_positions] = (
521+
params # TODO: List parameters are not updated if not accepted for the algorithm, we may have to warn/error if list is given
522+
)
522523
all_params = self.all_params
523524

524525
if self.sim_timeout:
@@ -528,7 +529,7 @@ def model_layer(q, all_params):
528529
q.put(self.setup.simulation(self.partype(*all_params)))
529530

530531
# starting a queue, where in python2.7 this is a multiprocessing class and can cause errors because of
531-
# incompability which the main thread. Therefore only for older Python version a workaround follows
532+
# incompability which the main thread. Therefore, only for older Python version a workaround follows
532533
que = Queue()
533534

534535
sim_thread = threading.Thread(target=model_layer, args=(que, all_params))

src/spotpy/algorithms/abc.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,7 @@ def sample(
7878
sets the limit
7979
"""
8080
self.set_repetiton(repetitions)
81-
print(
82-
"Starting the ABC algotrithm with " + str(repetitions) + " repetitions..."
83-
)
81+
print(f"Starting the ABC algorithm with {repetitions} repetitions...")
8482
# Initialize ABC parameters:
8583
randompar = self.parameter()["random"]
8684
self.nopt = randompar.size

src/spotpy/algorithms/dds.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,7 @@ def sample(self, repetitions, trials=1, x_initial=np.array([])):
281281
self.parameter()["minbound"],
282282
self.parameter()["maxbound"],
283283
)
284-
print(
285-
"Starting the DDS algotrithm with " + str(repetitions) + " repetitions..."
286-
)
284+
print(f"Starting the DDS algorithm with {repetitions} repetitions...")
287285

288286
number_of_parameters = (
289287
self.status.parameters
@@ -389,12 +387,14 @@ def calc_initial_para_configuration(
389387
(
390388
rep,
391389
[
392-
self.np_random.randint(
393-
int(self.min_bound[j]), int(self.max_bound[j]) + 1
390+
(
391+
self.np_random.randint(
392+
int(self.min_bound[j]), int(self.max_bound[j]) + 1
393+
)
394+
if discrete_flag[j]
395+
else self.min_bound[j]
396+
+ parameter_bound_range[j] * self.np_random.rand()
394397
)
395-
if discrete_flag[j]
396-
else self.min_bound[j]
397-
+ parameter_bound_range[j] * self.np_random.rand()
398398
for j in range(number_of_parameters)
399399
],
400400
)
@@ -471,8 +471,8 @@ def calculate_next_s_test(self, previous_x_curr, rep, rep_limit, r):
471471
self.min_bound[dec_var],
472472
self.max_bound[dec_var],
473473
)
474-
new_x_curr[
475-
dec_var
476-
] = new_value # change relevant decision variable value in s_test
474+
new_x_curr[dec_var] = (
475+
new_value # change relevant decision variable value in s_test
476+
)
477477

478478
return new_x_curr

src/spotpy/algorithms/demcz.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ def __init__(self, *args, **kwargs):
9191
* False: Simulationt results will not be saved
9292
"""
9393
kwargs["optimization_direction"] = "maximize"
94-
kwargs[
95-
"algorithm_name"
96-
] = "Differential Evolution Markov Chain (DE-MC) algorithm"
94+
kwargs["algorithm_name"] = (
95+
"Differential Evolution Markov Chain (DE-MC) algorithm"
96+
)
9797
super(demcz, self).__init__(*args, **kwargs)
9898

9999
def check_par_validity(self, par):
@@ -144,7 +144,7 @@ def sample(
144144

145145
self.set_repetiton(repetitions)
146146
print(
147-
"Starting the DEMCz algotrithm with " + str(repetitions) + " repetitions..."
147+
"Starting the DEMCz algorithm with " + str(repetitions) + " repetitions..."
148148
)
149149

150150
self.min_bound, self.max_bound = (

src/spotpy/algorithms/dream.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ def __init__(self, *args, **kwargs):
5454
"""
5555

5656
kwargs["optimization_direction"] = "maximize"
57-
kwargs[
58-
"algorithm_name"
59-
] = "DiffeRential Evolution Adaptive Metropolis (DREAM) algorithm"
57+
kwargs["algorithm_name"] = (
58+
"DiffeRential Evolution Adaptive Metropolis (DREAM) algorithm"
59+
)
6060
super(dream, self).__init__(*args, **kwargs)
6161

6262
def check_par_validity_bound(self, par):
@@ -270,7 +270,7 @@ def sample(
270270
):
271271
self.set_repetiton(repetitions)
272272
print(
273-
"Starting the DREAM algotrithm with " + str(repetitions) + " repetitions..."
273+
"Starting the DREAM algorithm with " + str(repetitions) + " repetitions..."
274274
)
275275
if nChains < 2 * delta + 1:
276276
print("Please use at least n=2*delta+1 chains!")

0 commit comments

Comments
 (0)