xsweep
Content-agnostic parameter sweeps for xarray: lift an expensive point function into a gridded, cached, resumable computation.
Some functions cannot be vectorised along the dims you want to sweep: a Monte-Carlo solver, an iterative scheme whose stopping point depends on the data, an external engine that takes one configuration at a time. numpy has nothing to offer there, and the loop you write instead quietly grows a cache, a resume path, a deduplication table and a way to guess how long it will all take.
xsweep is that loop, written once.
import numpy as np, xarray as xr
from xsweep import sweep, SweepPolicy
@sweep("loop(tau, ssa) -> reflectance()", store="runs/layer.zarr", version="1")
def layer(tau: float, ssa: float) -> float:
return monte_carlo(tau, ssa, n_photons=int(1e6)) # subprocess, GPU kernel, ...
space = xr.Dataset(
{"tau": ("tau", np.linspace(0.1, 3.0, 40)), "ssa": ("ssa", [0.9, 0.95, 1.0])}
)
print(layer.explain(space)) # what it will cost, zero calls
result = layer(space) # reflectance(tau: 40, ssa: 3)
Re-running that sweep makes zero calls. Interrupt it and relaunch: only the missing points are recomputed.
The three ideas
Semantics come from xarray, not from a second description. Variables sharing a dim vary together; variables on distinct dims multiply. A 1000 x 1000 map is a million zipped points, not a trillion product ones.
The contract describes the call, not the data. loop is one value per
call, vec a whole axis, const context handed over unchanged, and the
arrow names what one call produces. The same contract reads a parameter study
and a satellite scene.
Cache, output and resume are the same artefact. Results stream into a
zarr store with a status sidecar, which gives memoisation, bounded memory,
resumability and safe parallel writes at once. Deduplication, batch sizes and
executors are cost decisions on top, and a release gate enforces that they
never move a value.
Install
pip install xsweep
Python 3.11+, with xarray, zarr and numpy. Dask is an optional executor backend and no core path imports it.
To work on xsweep itself: pixi install && pixi run -e dev all.
Documentation
Everything lives on the site: https://walcark.github.io/xsweep/
- Why xsweep, including when it is the wrong tool
- Examples: ten pages, one idea each, on a real Monte-Carlo solver, with the actual output of every run
- Guide and API reference
- Limitations: what v0 deliberately does not do
- Benchmarks: per-point cost tracked across releases
Status
v0. Motivating consumers: adjeff (Smart-G sweeps, replacing its internal
SweepBundle and UniqueIndex), radtrans (the engine-agnostic half of its
sweep layer), and short sensitivity studies in Earth observation.
License
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 xsweep-0.4.1.tar.gz.
File metadata
- Download URL: xsweep-0.4.1.tar.gz
- Upload date:
- Size: 275.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0edd863949133fe76e6dfb695b19c1e945f8dea24056b4cb8d7a9a18ef9d5708
|
|
| MD5 |
86bda675fb5949c6be5667de785660ed
|
|
| BLAKE2b-256 |
a3d13530133c36b35651936de2ffec85dc81c947705280ac80415ed581ce5174
|
Provenance
The following attestation bundles were made for xsweep-0.4.1.tar.gz:
Publisher:
publish.yml on walcark/xsweep
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
xsweep-0.4.1.tar.gz -
Subject digest:
0edd863949133fe76e6dfb695b19c1e945f8dea24056b4cb8d7a9a18ef9d5708 - Sigstore transparency entry: 2582829398
- Sigstore integration time:
-
Permalink:
walcark/xsweep@f3f1a63aac838e36985061132f4bcd4d482c73b2 -
Branch / Tag:
refs/tags/v0.4.1 - Owner: https://github.com/walcark
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f3f1a63aac838e36985061132f4bcd4d482c73b2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file xsweep-0.4.1-py3-none-any.whl.
File metadata
- Download URL: xsweep-0.4.1-py3-none-any.whl
- Upload date:
- Size: 52.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
758484163c50ded9172a9ba6425e7b3e49044a3d00be8c3f326fab49d1153b0d
|
|
| MD5 |
8c8e53386769eb270b1269ebfa84ac41
|
|
| BLAKE2b-256 |
58303a9276b0a3d3ecb44a85ced26d78ac5ae1fcb5f513bfd9fbce5da4eb0c45
|
Provenance
The following attestation bundles were made for xsweep-0.4.1-py3-none-any.whl:
Publisher:
publish.yml on walcark/xsweep
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
xsweep-0.4.1-py3-none-any.whl -
Subject digest:
758484163c50ded9172a9ba6425e7b3e49044a3d00be8c3f326fab49d1153b0d - Sigstore transparency entry: 2582829406
- Sigstore integration time:
-
Permalink:
walcark/xsweep@f3f1a63aac838e36985061132f4bcd4d482c73b2 -
Branch / Tag:
refs/tags/v0.4.1 - Owner: https://github.com/walcark
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f3f1a63aac838e36985061132f4bcd4d482c73b2 -
Trigger Event:
push
-
Statement type: