Small utility to run a function over a Cartesian product of parameters and return results as an unstacked xarray object.
pip install xarray-sweepFor local development:
python -m venv .venv
source .venv/bin/activate
pip install -e .[dev]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()pytestpython -m build- Create a PyPI account and API token.
- Build artifacts (
python -m build). - Upload with Twine:
twine upload dist/*For TestPyPI first:
twine upload --repository testpypi dist/*A workflow is included at .github/workflows/ci.yml that runs tests on pull requests and pushes to main.