bayeswire
Bayeswire is the stdlib-only model declaration language and wire format for the
Bayescycle toolchain. It owns authoring semantics, resolved ModelMeta,
bayeswire_ir serialization, dimension sidecars, the wire-related documents in
root spec/, and the golden conformance corpus.
It contains no arrays, log-density math, binding, inference, plotting, or workflow orchestration.
Declare a model
from bayeswire import Data, Observed, Param, model
from bayeswire.constraints import Positive
from bayeswire.distributions import Normal, Truncated
@model
class LinearRegression:
alpha = Param(Normal(0.0, 1.0))
beta = Param(Normal(0.0, 1.0))
sigma = Param(
Truncated(Normal(0.0, 1.0), lower=0.0),
constraint=Positive(),
)
x = Data.vector()
mu = alpha + beta * x
y = Observed(Normal(mu, sigma))
Resolve and serialize without binding data:
from bayeswire.ir import canonical_bytes, meta_from_dict, meta_to_dict
from bayeswire.model import model_meta
meta = model_meta(LinearRegression)
document = meta_to_dict(meta)
wire_bytes = canonical_bytes(meta)
restored = meta_from_dict(document)
ModelMeta is the serialization boundary. Decoding executes no user code.
Canonical bytes are stable input to model hashes and downstream conformance.
Dimension labels and coordinates travel in a separate sidecar and do not change
the model hash.
Composition
Submodel(Model) reuses a complete model under an explicit namespace. It
prefixes and flattens the child's parameters, data, dimensions, expressions,
and stochastic factors before serialization; hierarchy is not an IR concept.
with_prior(Target, prior=Source) returns a new closed model with a complete
same-name replacement prior:
from bayeswire import Param, model, with_prior
from bayeswire.constraints import Positive
from bayeswire.distributions import HalfNormal, Normal
@model
class SimulationPrior:
alpha = Param(Normal(0.0, 0.25))
beta = Param(Normal(1.0, 0.2))
sigma = Param(HalfNormal(0.5), constraint=Positive())
SimulationModel = with_prior(LinearRegression, prior=SimulationPrior)
The source must be structurally prior-only and provide every target parameter
with the same name, constraint, size, and dimensions. Composition is immutable
and closes to ordinary flat bayeswire_ir v1. The precise durable rules are in
docs/invariants.md.
Contracts and corpus
The root spec/ defines the shared interoperability formats.
The corpus under
src/bayeswire/corpus/ contains golden IR documents,
canonical hashes, data documents, and Bayesjax-oracle evaluation fixtures.
Producers reproduce its bytes; consumers evaluate it within the spec tolerance.
Any tag, field, or canonical-byte change requires an explicit IR-version decision and deliberate corpus regeneration.
Development
uv run ruff format --check .
uv run ruff check .
uv run ty check
uv run pytest
The suite includes a no-JAX import walk and produce-conformance. See
AGENTS.md for working rules.
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 bayeswire-0.7.0.tar.gz.
File metadata
- Download URL: bayeswire-0.7.0.tar.gz
- Upload date:
- Size: 213.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3019036dbc35f8e592e282a919dc8857a45173c765270468f81960e9f24caaff
|
|
| MD5 |
f3805f0fd8bfb7d4b46d383b634a1471
|
|
| BLAKE2b-256 |
305c882bc31f1b60884b9ac594d4f6f026423841a9f2520150de27fad48f5774
|
File details
Details for the file bayeswire-0.7.0-py3-none-any.whl.
File metadata
- Download URL: bayeswire-0.7.0-py3-none-any.whl
- Upload date:
- Size: 249.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bbbc65792ed34e266dea6a9ce6dc05cecdb56f66aa9bf31d706afeedf4d41750
|
|
| MD5 |
10ab1760081902d599d95ec7f6f75f6e
|
|
| BLAKE2b-256 |
5a1aad38800bd2e7d4d18866679b23c1f27fc3cd5c3052c74ca82b1331886cca
|