parameterrun 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,63 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ pull_request:
7
+
8
+ jobs:
9
+ test:
10
+ name: ${{ matrix.os }} / py${{ matrix.python-version }}
11
+ runs-on: ${{ matrix.os }}
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ os: [ ubuntu-latest, macos-latest, windows-latest ]
16
+ python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13" ]
17
+
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+
21
+ - uses: actions/setup-python@v5
22
+ with:
23
+ python-version: ${{ matrix.python-version }}
24
+
25
+ - name: Install uv
26
+ run: python -m pip install uv
27
+
28
+ - name: Sync environment
29
+ run: uv sync
30
+
31
+ - name: Lint
32
+ run: uv run ruff check .
33
+
34
+ # - name: Format check
35
+ # run: uv run ruff format --check .
36
+
37
+ # - name: Type check
38
+ # run: uv run mypy
39
+
40
+ - name: Tests
41
+ run: uv run pytest
42
+
43
+ build:
44
+ name: Build package
45
+ runs-on: ubuntu-latest
46
+ steps:
47
+ - uses: actions/checkout@v4
48
+
49
+ - uses: actions/setup-python@v5
50
+ with:
51
+ python-version: "3.9"
52
+
53
+ - name: Install uv
54
+ run: python -m pip install uv
55
+
56
+ - name: Sync environment
57
+ run: uv sync
58
+
59
+ - name: Build
60
+ run: uv run python -m build
61
+
62
+ - name: Check distributions
63
+ run: uv run twine check --strict dist/*
@@ -0,0 +1,50 @@
1
+ name: Publish
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v0.1.0"
7
+
8
+ jobs:
9
+ build:
10
+ runs-on: ubuntu-latest
11
+ permissions:
12
+ contents: read
13
+
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+
17
+ - uses: actions/setup-python@v5
18
+ with:
19
+ python-version: "3.9"
20
+
21
+ - name: Install uv
22
+ run: python -m pip install uv
23
+
24
+ - name: Sync environment
25
+ run: uv sync
26
+
27
+ - name: Build distributions
28
+ run: uv run python -m build
29
+
30
+ - name: Check distributions
31
+ run: uv run twine check --strict dist/*
32
+
33
+ - uses: actions/upload-artifact@v4
34
+ with:
35
+ name: dist
36
+ path: dist/
37
+
38
+ publish:
39
+ needs: build
40
+ runs-on: ubuntu-latest
41
+ permissions:
42
+ id-token: write
43
+
44
+ steps:
45
+ - uses: actions/download-artifact@v4
46
+ with:
47
+ name: dist
48
+ path: dist/
49
+
50
+ - uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,210 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ #uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ #poetry.lock
109
+ #poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ #pdm.lock
116
+ #pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ #pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # SageMath parsed files
135
+ *.sage.py
136
+
137
+ # Environments
138
+ .env
139
+ .envrc
140
+ .venv
141
+ env/
142
+ venv/
143
+ ENV/
144
+ env.bak/
145
+ venv.bak/
146
+
147
+ # Spyder project settings
148
+ .spyderproject
149
+ .spyproject
150
+
151
+ # Rope project settings
152
+ .ropeproject
153
+
154
+ # mkdocs documentation
155
+ /site
156
+
157
+ # mypy
158
+ .mypy_cache/
159
+ .dmypy.json
160
+ dmypy.json
161
+
162
+ # Pyre type checker
163
+ .pyre/
164
+
165
+ # pytype static type analyzer
166
+ .pytype/
167
+
168
+ # Cython debug symbols
169
+ cython_debug/
170
+
171
+ # PyCharm
172
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
173
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
174
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
175
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
176
+ .idea/
177
+
178
+ # Abstra
179
+ # Abstra is an AI-powered process automation framework.
180
+ # Ignore directories containing user credentials, local state, and settings.
181
+ # Learn more at https://abstra.io/docs
182
+ .abstra/
183
+
184
+ # Visual Studio Code
185
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
186
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
187
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
188
+ # you could uncomment the following to ignore the entire vscode folder
189
+ # .vscode/
190
+
191
+ # Ruff stuff:
192
+ .ruff_cache/
193
+
194
+ # PyPI configuration file
195
+ .pypirc
196
+
197
+ # Cursor
198
+ # Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
199
+ # exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
200
+ # refer to https://docs.cursor.com/context/ignore-files
201
+ .cursorignore
202
+ .cursorindexingignore
203
+
204
+ # Marimo
205
+ marimo/_static/
206
+ marimo/_lsp/
207
+ __marimo__/
208
+
209
+ # uv files
210
+ uv.lock
@@ -0,0 +1,10 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented in this file.
4
+
5
+ The format is based on Keep a Changelog and the project follows Semantic Versioning.
6
+
7
+ ## [0.1.0] - 2026-03-25
8
+
9
+ ### Added
10
+ - Initial public release of `parameterrun`
@@ -0,0 +1,34 @@
1
+ # Contributing
2
+
3
+ Thanks for contributing to `parameterrun`.
4
+
5
+ ## Development setup
6
+
7
+ ```bash
8
+ uv sync --group dev
9
+ ```
10
+
11
+ If you do not use `uv`, create a virtual environment and install equivalent dev dependencies from `pyproject.toml`.
12
+
13
+ ## Run quality checks
14
+
15
+ ```bash
16
+ uv run pytest
17
+ uv run ruff check .
18
+ uv run mypy src/parameterrun
19
+ uv run python -m build
20
+ uv run python -m twine check dist/*
21
+ ```
22
+
23
+ ## Pull request guidelines
24
+
25
+ - Keep PRs focused and small when possible.
26
+ - Add or update tests for behavior changes.
27
+ - Update `README.md` and `CHANGELOG.md` when user-facing behavior changes.
28
+ - Ensure all checks pass before requesting review.
29
+
30
+ ## Release notes
31
+
32
+ - Add entries to the `[Unreleased]` section in `CHANGELOG.md`.
33
+ - At release time, move those entries under a versioned heading.
34
+
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2026, David Fernandez Fernandez
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,267 @@
1
+ Metadata-Version: 2.4
2
+ Name: parameterrun
3
+ Version: 0.1.0
4
+ Summary: Parallel parameter sweeps with joblib/MPI and tqdm progress bars.
5
+ Project-URL: Homepage, https://github.com/Davtax/ParameterRun
6
+ Project-URL: Repository, https://github.com/Davtax/ParameterRun
7
+ Project-URL: Issues, https://github.com/Davtax/ParameterRun/issues
8
+ Project-URL: Changelog, https://github.com/Davtax/ParameterRun/blob/main/CHANGELOG.md
9
+ Author-email: David Fernández-Fernández <david.fernandezf@hotmail.com>
10
+ License-Expression: BSD-3-Clause
11
+ License-File: LICENSE
12
+ Keywords: joblib,mpi,parallel,parameter-sweep,python,scientific-computing
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: License :: OSI Approved :: BSD License
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3 :: Only
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Topic :: Scientific/Engineering
24
+ Classifier: Typing :: Typed
25
+ Requires-Python: >=3.9
26
+ Requires-Dist: joblib>=1.3
27
+ Requires-Dist: numpy>=1.23
28
+ Requires-Dist: tqdm>=4.66
29
+ Provides-Extra: mpi
30
+ Requires-Dist: mpi4py>=3.1; extra == 'mpi'
31
+ Description-Content-Type: text/markdown
32
+
33
+ # ParameterRun
34
+
35
+ `parameterrun` is a lightweight utility for running parameter sweeps in Python with a simple, function-based API.
36
+
37
+ It is designed for scientific and numerical workflows where you want to evaluate a function over one or more parameter
38
+ grids, optionally in parallel, while keeping progress bars and output reshaping convenient.
39
+
40
+ The package supports:
41
+
42
+ - single-parameter scans
43
+ - multi-parameter scans
44
+ - grouped parameters that must vary together
45
+ - parallel execution with `joblib`
46
+ - MPI execution with `mpi4py`
47
+ - automatic reshaping of outputs into arrays
48
+ - functions returning either one output or multiple outputs
49
+
50
+ ## Installation
51
+
52
+ ### With `pip`
53
+
54
+ ```bash
55
+ pip install parameterrun
56
+ ```
57
+
58
+ ### With optional MPI support
59
+
60
+ ```bash
61
+ pip install parameterrun[mpi]
62
+ ```
63
+
64
+ ## Basic idea
65
+
66
+ The main entry point is:
67
+
68
+ ```python
69
+ from parameterrun import parameterrun
70
+ ```
71
+
72
+ The function `parameterrun(...)` evaluates a user-defined function over a set of parameter values. The parameters to
73
+ sweep are identified by their names exactly as they appear in the target function signature. Additional fixed arguments
74
+ can be passed as keyword arguments.
75
+
76
+ ## Quick start
77
+
78
+ ### 1. Single parameter
79
+
80
+ ```python
81
+ from parameterrun import parameterrun
82
+
83
+
84
+ def square(x):
85
+ return x ** 2
86
+
87
+
88
+ result = parameterrun(square, param_names="x", param_values=[0, 1, 2, 3], n_workers=1, )
89
+
90
+ print(result) # array([0, 1, 4, 9])
91
+ ```
92
+
93
+ ### 2. Multiple independent parameters
94
+
95
+ This creates a Cartesian product of the parameter groups.
96
+
97
+ ```python
98
+ from parameterrun import parameterrun
99
+
100
+
101
+ def f(x, y, scale=1):
102
+ return scale * (x + y)
103
+
104
+
105
+ result = parameterrun(f, param_names=["x", "y"], param_values=[[1, 2, 3], [10, 20], ], scale=2, )
106
+
107
+ result = result.reshape(3, 2)
108
+ print(result.shape) # (3, 2)
109
+ ```
110
+
111
+ ### 3. Grouped parameters
112
+
113
+ Parameters in the same group vary together and must have the same number of values.
114
+
115
+ ```python
116
+ from parameterrun import parameterrun
117
+
118
+
119
+ def f(x, y, z):
120
+ return x + y + z
121
+
122
+
123
+ result = parameterrun(f, param_names=[["x", "y"], ["z"]], param_values=[[[1, 2], [10, 20]], # (x, y) = (1,10), (2,20)
124
+ [[100, 200, 300]], # z varies independently
125
+ ], n_workers=1, )
126
+
127
+ result = result.reshape(2, 3)
128
+ print(result.shape) # (2, 3)
129
+ ```
130
+
131
+ This grouped-input mode is useful when some parameters are logically linked and should not be combined independently.
132
+
133
+ ## Multiple outputs
134
+
135
+ If the target function returns a tuple, parameterrun returns a list of arrays, one per output channel.
136
+
137
+ ```python
138
+ from parameterrun import parameterrun
139
+
140
+
141
+ def stats(x):
142
+ return x + 1, x ** 2
143
+
144
+
145
+ mean_like, square_like = parameterrun(stats, param_names="x", param_values=[1, 2, 3], n_workers=1, )
146
+
147
+ print(mean_like)
148
+ # array([2, 3, 4])
149
+
150
+ print(square_like) # array([1, 4, 9])
151
+ ```
152
+
153
+ If the function returns a single object, the result is returned as a single array when reshaping is possible.
154
+
155
+ ## Parallel backend
156
+
157
+ `parameterrun` supports two execution backends:
158
+
159
+ - `joblib`: a simple, local parallelization library that works well for most use cases.
160
+ - `mpi`: a distributed parallelization approach using MPI, suitable for running on clusters or supercomputers.
161
+
162
+ If `backend=None`, the package tries to detect whether MPI is available. If MPI is not available, it falls back to
163
+ `joblib`; otherwise it uses MPI.
164
+
165
+ ### Joblib backend
166
+
167
+ ```python
168
+ result = parameterrun(my_function, param_names=["x", "y"], param_values=[[1, 2, 3], [4, 5]], backend="joblib",
169
+ n_workers=-1, )
170
+ ```
171
+
172
+ If `n_workers=1`, the function runs serially without spawning joblib workers.
173
+
174
+ ### MPI backend
175
+
176
+ ```python
177
+ result = parameterrun(my_function, param_names=["x", "y"], param_values=[[1, 2, 3], [4, 5]], backend="mpi", )
178
+ ```
179
+
180
+ Run the script with MPI, for example:
181
+
182
+ ```bash
183
+ mpirun -n 4 python my_script.py
184
+ ```
185
+
186
+ Under MPI, only rank 0 returns the final result; the other ranks return `None`.
187
+
188
+ ## Progress bars and verbosity
189
+
190
+ By default, progress bars are enabled:
191
+
192
+ ```python
193
+ result = parameterrun(my_function, param_names="x", param_values=[1, 2, 3], pbar_bool=True, )
194
+ ```
195
+
196
+ You can also pass extra keyword arguments to `tqdm` through `pbar_kwargs`:
197
+
198
+ ```python
199
+ result = parameterrun(my_function, param_names="x", param_values=[1, 2, 3], pbar_kwargs={"leave": False}, )
200
+ ```
201
+
202
+ Verbose logging can be enabled with:
203
+
204
+ ```python
205
+ result = parameterrun(my_function, param_names="x", param_values=[1, 2, 3], verbose=True, )
206
+ ```
207
+
208
+ The progress-bar description is generated automatically from the function name and parameter names, unless you provide
209
+ `desc` explicitly.
210
+
211
+ ## API reference
212
+
213
+ `parameterrun`
214
+
215
+ ```python
216
+ parameterrun(fun, param_names, param_values, n_workers=-1, pbar_bool=True, verbose=False, pbar_kwargs=None,
217
+ reshape=True, backend=None, desc=None, **kwargs, )
218
+ ```
219
+
220
+ * `fun`: function to evaluate
221
+ * `param_names`: parameter name or grouped parameter names
222
+ * `param_values`: values corresponding to `param_names`
223
+ * `n_workers`: number of workers for `joblib`
224
+ * `pbar_bool`: enable or disable progress bars
225
+ * `verbose`: print backend and timing information
226
+ * `pbar_kwargs`: additional keyword arguments passed to tqdm
227
+ * `reshape`: reshape results into arrays when possible
228
+ * `backend`: `"joblib"`, `"mpi"`, or `None`
229
+ * `desc`: custom progress-bar label
230
+ * `**kwargs`: extra fixed keyword arguments forwarded to `fun`
231
+
232
+ ## Input formats
233
+
234
+ `parameterrun` accepts three input styles.
235
+
236
+ ### A. Single parameter
237
+
238
+ ```python
239
+ param_names = "x"
240
+ param_values = [1, 2, 3]
241
+ ```
242
+
243
+ ### B. Multiple independent parameters
244
+
245
+ ```python
246
+ param_names = ["x", "y"]
247
+ param_values = [[1, 2, 3], [10, 20], ]
248
+ ```
249
+
250
+ ### C. Multiple groups of parameters
251
+
252
+ ```python
253
+ param_names = [["x", "y"], ["z"]]
254
+ param_values = [[[1, 2], [10, 20]], [[100, 200, 300]], ]
255
+ ```
256
+
257
+ ## Development checks
258
+
259
+ Before opening a PR or publishing a release, run:
260
+
261
+ ```bash
262
+ pytest
263
+ ruff check .
264
+ mypy src/parameterrun
265
+ python -m build
266
+ python -m twine check dist/*
267
+ ```