Skip to main content

xsweep

Content-agnostic parameter sweeps for xarray: lift an expensive point function into a gridded, cached, resumable computation.

Documentation and examples

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/

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

Apache License 2.0.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xsweep-0.4.1.tar.gz (275.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xsweep-0.4.1-py3-none-any.whl (52.8 kB view details)

Uploaded Python 3

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

Hashes for xsweep-0.4.1.tar.gz
Algorithm Hash digest
SHA256 0edd863949133fe76e6dfb695b19c1e945f8dea24056b4cb8d7a9a18ef9d5708
MD5 86bda675fb5949c6be5667de785660ed
BLAKE2b-256 a3d13530133c36b35651936de2ffec85dc81c947705280ac80415ed581ce5174

See more details on using hashes here.

Provenance

The following attestation bundles were made for xsweep-0.4.1.tar.gz:

Publisher: publish.yml on walcark/xsweep

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for xsweep-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 758484163c50ded9172a9ba6425e7b3e49044a3d00be8c3f326fab49d1153b0d
MD5 8c8e53386769eb270b1269ebfa84ac41
BLAKE2b-256 58303a9276b0a3d3ecb44a85ced26d78ac5ae1fcb5f513bfd9fbce5da4eb0c45

See more details on using hashes here.

Provenance

The following attestation bundles were made for xsweep-0.4.1-py3-none-any.whl:

Publisher: publish.yml on walcark/xsweep

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.4.1 This release

2 files

0.4.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page