Simple grid search utility that returns xarray outputs.
Project description
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
- 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/*
GitHub Actions CI
A workflow is included at .github/workflows/ci.yml that runs tests on pull requests and pushes to main.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file xarray_sweep-0.1.6.tar.gz.
File metadata
- Download URL: xarray_sweep-0.1.6.tar.gz
- Upload date:
- Size: 11.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed17140d84e82ea82a7abe96c530b1812e445bf796f71b6207dcb9d93c627495
|
|
| MD5 |
f78c42ffef27b8ff0f27401a1356d55f
|
|
| BLAKE2b-256 |
38db02f79bfb21653eb95d13ca02ddcdce70eea9e21ba5a4490d83f104de047b
|
File details
Details for the file xarray_sweep-0.1.6-py3-none-any.whl.
File metadata
- Download URL: xarray_sweep-0.1.6-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
387d2f712373a084a276f86d946cc3f0383c411534d959c230a862353186823d
|
|
| MD5 |
585acb38bc5805eded3ea84f9d272840
|
|
| BLAKE2b-256 |
308737c8840b2f9ccb24b26663b87fb6a4a9cf97a15f9995ce64e6fd230909c9
|