Skip to content

About

xarray-sweep is a lightweight Python utility for running parameter sweeps over Cartesian grids and collecting results as labeled xarray objects. It executes a function across all parameter combinations, preserves coordinates for each run, and returns an unstacked xarray.DataArray or xarray.Dataset ready for analysis and visualization.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

7 Commits

Folders and files

Repository files navigation

xarray-sweep

Small utility to run a function over a Cartesian product of parameters and return results as an unstacked xarray object.

Install

pip install xarray-sweep

For local development:

python -m venv .venv
source .venv/bin/activate
pip install -e .[dev]

Usage

import xarray as xr
from xarray_sweep import xarray_sweep


def model(a: float, b: float):
    return a + b

out = xarray_sweep(model, a=[0.1, 0.2], b=[1.0, 2.0])
print(out)

xarray_sweep runs sequentially by default. To execute combinations with Dask:

out = xarray_sweep(model, use_dask=True, a=[0.1, 0.2], b=[1.0, 2.0])

To build a delayed computation (for distributed workflows), use compute=False:

delayed_out = xarray_sweep(model, use_dask=True, compute=False, a=[0.1, 0.2], b=[1.0, 2.0])

Then you can compute this later with

out = delayed_out.compute()

or if you like you can use a progress bar with:

from dask.diagnostics import ProgressBar
with ProgressBar():
   out = delayed_out.compute()

Run tests

pytest

Build distribution artifacts

python -m build

Publish to PyPI

  1. Create a PyPI account and API token.
  2. Build artifacts (python -m build).
  3. Upload with Twine:
twine upload dist/*

For TestPyPI first:

twine upload --repository testpypi dist/*

GitHub Actions CI

A workflow is included at .github/workflows/ci.yml that runs tests on pull requests and pushes to main.

About

xarray-sweep is a lightweight Python utility for running parameter sweeps over Cartesian grids and collecting results as labeled xarray objects. It executes a function across all parameter combinations, preserves coordinates for each run, and returns an unstacked xarray.DataArray or xarray.Dataset ready for analysis and visualization.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages