Metadata-Version: 2.4
Name: sweepexp
Version: 1.0.3
Summary: A python package for running parallel experiments across parameter grids with MPI.
Author-email: Silvano Gordian Rosenau <silvano.rosenau@uni-hamburg.de>
License: MIT License
        
        Copyright (c) 2025, Silvano Gordian Rosenau
        
        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.
        
Project-URL: Repository, https://github.com/Gordi42/sweepexp
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Development Status :: 5 - Production/Stable
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: lazypimp
Requires-Dist: xarray
Requires-Dist: dill
Provides-Extra: full
Requires-Dist: zarr; extra == "full"
Requires-Dist: netCDF4; extra == "full"
Dynamic: license-file

![Read the Docs](https://img.shields.io/readthedocs/sweepexp)
![tests](https://github.com/Gordi42/sweepexp/actions/workflows/test.yml/badge.svg)
[![codecov](https://codecov.io/github/Gordi42/sweepexp/graph/badge.svg?token=SHVDIIOL8Y)](https://codecov.io/github/Gordi42/sweepexp)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
![GitHub License](https://img.shields.io/github/license/Gordi42/sweepexp)
[![DOI](https://zenodo.org/badge/921273341.svg)](https://doi.org/10.5281/zenodo.14779187)

<p align="center">
<img src="docs/source/_static/sweepexp_logo.png?raw=true">
</p>

A python package for running parallel experiments across parameter grids with MPI.

## Features

- **Flexible Experimentation with Parameter Grids:** SweepExp simplifies running experiments over a grid of parameter combinations. Results are stored in an xarray dataset for easy access and analysis.
- **Parallelization:** Support for parallelization using multiprocessing, or MPI for high-performance computing.
- **User-Friendly API:**  Define the function to be tested, set up parameter sweeps, and specify return types effortlessly.

## Installation

SweepExp can be installed via pip:

```bash
pip install sweepexp
```

## Usage
The followin example shows how to setup a simple experiment that is run on a grid of parameters. Where each parameter combination is run in parallel on separate processes. 

```python

from sweepexp import SweepExpParallel

# Define a function to be tested
def my_custom_experiment(x: float, y: float) -> dict:
    """Add and multiply two numbers."""
    return {"addition": x + y, "multiplication": x * y}

sweep = SweepExpParallel(
    func = my_custom_experiment,
    parameters = { "x": [1, 2], "y": [3, 4, 5] },
)

sweep.run()

print(sweep.data)
```

with the output:
```
<xarray.Dataset> Size: 160B
Dimensions:         (x: 2, y: 3)
Coordinates:
    * x               (x) int64 16B 1 2
    * y               (y) int64 24B 3 4 5
Data variables:
    status          (x, y) <U1 24B 'C' 'C' 'C' 'C' 'C' 'C'
    addition        (x, y) float64 48B 4.0 5.0 6.0 5.0 6.0 7.0
    multiplication  (x, y) float64 48B 3.0 4.0 5.0 6.0 8.0 10.0
```

For more information on how to use the package, please refer to the [documentation](https://sweepexp.readthedocs.io/)

## How to cite

```
@software{Rosenau_sweepexp_2025,
          author = {Rosenau, Silvano Gordian},
          doi = {10.5281/zenodo.14779187},
          month = jan,
          title = {{SweepExp: A python package for running parallel experiments across parameter grids.}},
          url = {https://github.com/Gordi42/sweepexp},
          version = {1.0.2},
          year = {2025}
}
```

## Author
- [Silvano Gordian Rosenau](silvano.rosenau@uni-hamburg.de)

## License
SweepExp is licensed under the MIT License. See [LICENSE](LICENSE) for more information.
