Metadata-Version: 2.5
Name: parstudy
Version: 0.2.0
Summary: Backend-agnostic parameter and variant studies for simulations
Project-URL: Homepage, https://github.com/FraunhIEE-UniKassel-PowSysStability/parstudy
Project-URL: Repository, https://github.com/FraunhIEE-UniKassel-PowSysStability/parstudy
Project-URL: Bug Tracker, https://github.com/FraunhIEE-UniKassel-PowSysStability/parstudy/issues
Project-URL: Changelog, https://github.com/FraunhIEE-UniKassel-PowSysStability/parstudy/blob/main/CHANGELOG.md
Author-email: Sciemon <simon.eberlein@gmx.de>
License: MIT License
        
        Copyright (c) 2026 FraunhIEE-UniKassel-PowSysStability
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: design of experiments,latin hypercube,parameter study,sensitivity analysis,simulation,sobol
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: numpy>=1.24
Requires-Dist: pandas>=2.0
Provides-Extra: all
Requires-Dist: joblib>=1.3; extra == 'all'
Requires-Dist: matplotlib>=3.7; extra == 'all'
Requires-Dist: scipy>=1.10; extra == 'all'
Provides-Extra: dev
Requires-Dist: build; extra == 'dev'
Requires-Dist: joblib>=1.3; extra == 'dev'
Requires-Dist: matplotlib>=3.7; extra == 'dev'
Requires-Dist: pytest>=7.0; extra == 'dev'
Requires-Dist: ruff; extra == 'dev'
Requires-Dist: scipy>=1.10; extra == 'dev'
Requires-Dist: twine; extra == 'dev'
Provides-Extra: parallel
Requires-Dist: joblib>=1.3; extra == 'parallel'
Provides-Extra: sampling
Requires-Dist: scipy>=1.10; extra == 'sampling'
Provides-Extra: test
Requires-Dist: joblib>=1.3; extra == 'test'
Requires-Dist: matplotlib>=3.7; extra == 'test'
Requires-Dist: pytest>=7.0; extra == 'test'
Requires-Dist: scipy>=1.10; extra == 'test'
Provides-Extra: viz
Requires-Dist: matplotlib>=3.7; extra == 'viz'
Description-Content-Type: text/markdown

# parstudy

Parameter and variant studies for simulation models, independent of the simulation backend.

You describe **each quantity to vary on its own** as a `ModelParameter` - its `name`, the `values` to sweep, an optional `default`, and an optional list of model attributes it `affects`. Attributes a parameter `affects` are snapshotted at the start of the study, written for you before every serial run (verbatim, or combined with their baseline when `mode="multiply"` / `"add"`), and restored at the end - so `evaluate` only has to do what `affects` cannot. You give a `Study` **one** callable, `evaluate(values)`, that does any remaining setup, runs the model and reduces one run to `(scalars, raw)`. `Study.run()` sweeps the parameters, restores the model, and hands back a tidy MultiIndex table plus correlation / regression / Sobol / plotting helpers.

```python
import parstudy as ps

# `affects` are written (and restored) for you; `mode="multiply"` sweeps a factor
speed = ps.ModelParameter("speed", ps.linspace(0.5, 2.0, 6), affects=[(model, "speed")])
drag = ps.ModelParameter("drag", [0.5, 1.0, 2.0], default=1.0, mode="multiply",
                         affects=[(model, "drag")])

def evaluate(values):
    raw = run(model)                       # model.speed / model.drag already set
    return {"range": raw.range, "peak": raw.peak}, raw

study = ps.Study([speed, drag], evaluate)

results = study.run(verbose=1)        # one-at-a-time: each parameter swept, others at default
results.evaluations                   # MultiIndex table: ("parameters", ...) and ("results", ...)
results.varied                        # Series: which parameter each run swept
results.correlation()                 # parameter x metric
results.regression(standardized=True) # comparable sensitivity coefficients
results.plot()                        # metric vs value, one panel per parameter
results.raw(3)                        # the full artefact of run 3
```

Switch the design with one argument: `strategy="grid"`, `ps.latin_hypercube(120)`,
`ps.sobol(256)` (then `results.sobol_indices()`), or `ps.from_design("design.csv")`.
`run(raw_store="dir")` streams raw results to disk and enables `run(resume=True)`
and `run(parallel=N)`.

## Why not a `for` loop?

A hand-written sweep tangles parameter definitions, ranges, model mutation, running, collecting and restoring - and you rewrite it for every study. `parstudy` separates them: parameters are reusable objects, the pipeline is one callable, the affected model state is snapshotted and restored even on error, and the results arrive in one schema the analysis helpers understand. See the [getting-started tutorial](docs/tutorials/getting_started.qmd) for the full argument and a worked example.

## Install

```
pip install -e .                    # numpy + pandas only
pip install -e ".[viz]"             # + matplotlib (all plots)
pip install -e ".[sampling]"        # + scipy   (sobol strategy / indices)
pip install -e ".[parallel]"        # + joblib  (run(parallel=N))
pip install -e ".[all]"             # everything above
```

## License

MIT, see [LICENSE](LICENSE).
