tissage-cosmique
Cosmological computations with provenance tracking, emulator support, and hot-swap dispatch.
Built on macon (CRUD database framework) and tisserande (execution provenance tracking).
Overview
tissage-cosmique wraps pyccl (the Core Cosmology Library) to:
- Run cosmological computations (distances, power spectra) with automatic provenance tracking
- Store inputs, outputs, and provenance in a database via tisserande's
@trackdecorator - Build emulators (fast surrogate models) trained on stored computation results
- Hot-swap emulators for the original code — transparently replace pyccl calls at runtime
Installation
pip install tissage-cosmique # core
pip install "tissage-cosmique[pyccl]" # pyccl computations
pip install "tissage-cosmique[emulators]" # GP emulator (scikit-learn)
pip install "tissage-cosmique[tensorflow]" # TensorFlow backend
pip install "tissage-cosmique[pytorch]" # PyTorch backend
pip install "tissage-cosmique[symbolic]" # PySR symbolic regression
pip install "tissage-cosmique[dashboard]" # Plotly/Dash web dashboard
pip install "tissage-cosmique[dev]" # development (tests, lint, typing)
Quick Start
import numpy as np
from tissage_cosmique.computations.distances import comoving_angular_distance
from tissage_cosmique.emulators import GPEmulator, build_training_data, params_to_feature_matrix
from tissage_cosmique.swap import swappable, register
# Define cosmological parameters
params = dict(Omega_c=0.2589, Omega_b=0.0486, h=0.6774,
n_s=0.9667, sigma8=0.8159, Omega_k=0.0, w0=-1.0, wa=0.0)
a_grid = np.linspace(0.2, 0.8, 50)
# Run the computation (automatically tracked by @track)
distances = comoving_angular_distance(params, a_grid)
# Train a GP emulator
samples = [{**params, "Omega_c": np.random.uniform(0.22, 0.32),
"h": np.random.uniform(0.62, 0.75)} for _ in range(50)]
X, y = build_training_data(comoving_angular_distance, samples, a_grid,
param_names=["Omega_c", "h", "sigma8"])
emu = GPEmulator(feature_names=["Omega_c", "h", "sigma8", "a"])
emu.fit(X, y)
# Hot-swap: replace pyccl with the emulator (40x faster)
compute = swappable(comoving_angular_distance)
register(comoving_angular_distance, emu, ["Omega_c", "h", "sigma8"])
result = compute(params, a_grid) # uses the emulator
Architecture
tissage_cosmique/
├── computations/ pyccl-wrapping functions with @track provenance
├── emulators/ training, 4 backends, validation, inversion, latent space
│ ├── backends/ GP, TensorFlow, PyTorch, PySR
│ └── codecs/ PCA and autoencoder for latent space encoding
├── swap/ hot-swap registry and dispatch
├── dashboard/ Plotly/Dash web interface
├── db/ domain tables (CosmologyParams, EmulatorRecord, CodecRecord)
├── models/ Pydantic models
├── db_oper/ macon TableOperations
├── local_async/ async session-managed operations
├── local_sync/ synchronous wrappers
├── router/ FastAPI endpoints
├── cli/ Click CLI entry points
└── config.py Pydantic Settings configuration
Three-Package Design
| Package | Role |
|---|---|
| macon | Generic CRUD database framework (SQLAlchemy, FastAPI, Click) |
| tisserande | Execution provenance tracking (@track decorator, DAG storage) |
| tissage-cosmique | Cosmology computations, emulators, hot-swap (this package) |
Emulator Backends
| Backend | Class | Key Feature |
|---|---|---|
| Gaussian Process | GPEmulator |
Uncertainty estimates, best at small N |
| TensorFlow | TensorFlowEmulator |
Scales to large N |
| PyTorch | PyTorchEmulator |
Gradient-based inversion |
| Symbolic (PySR) | SymbolicEmulator |
Discovers closed-form expressions |
Latent Space Emulation
Compress output curves into a low-dimensional latent code, emulate in latent space, then decode:
from tissage_cosmique.emulators import PCACodec, LatentEmulator, GPEmulator
le = LatentEmulator(
codec=PCACodec(n_components=3),
emulator_factory=lambda: GPEmulator(feature_names=["Omega_c", "h", "sigma8"]),
)
le.fit(samples, comoving_angular_distance, a_grid, param_names=["Omega_c", "h", "sigma8"])
curve = le.predict(params) # full output curve from 3 latent dimensions
Emulator Inversion
Recover cosmological parameters from target observations:
result = emu.invert(
y_target=observed_distances,
free_params=["Omega_c", "h"],
fixed_params={"sigma8": 0.8159, "a": a_grid},
x0={"Omega_c": 0.27, "h": 0.68},
bounds={"Omega_c": (0.2, 0.35), "h": (0.6, 0.8)},
)
print(result.x_solution) # {"Omega_c": 0.259, "h": 0.677}
Dashboard
Interactive web interface for exploring stored data:
tissage-cosmique-dashboard --db-url sqlite+aiosqlite:///my_database.db
4 tabs: Cosmology Parameters, Provenance Explorer, Emulator Registry, Codec Registry.
CLI
tissage-cosmique-local # local DB admin (CRUD for all tables)
tissage-cosmique-server # FastAPI/uvicorn server
tissage-cosmique-dashboard # Plotly/Dash web dashboard
Examples
See the examples/ directory for Jupyter notebooks:
emulator_distances.ipynb— GP emulator for comoving angular distanceemulator_power_spectrum.ipynb— multi-grid emulation of P(k, a)compare_emulator_backends.ipynb— GP vs TF vs PyTorch vs PySR comparisonfull_pipeline.ipynb— complete loop: DB → pyccl → provenance → emulatorhot_swap_demo.ipynb— transparent emulator dispatch (40x speedup)inversion_demo.ipynb— parameter recovery from observationslatent_emulator_demo.ipynb— PCA and autoencoder latent space emulation
Development
pip install -e ".[dev]"
pytest tests/ # run test suite
ruff check src/ tests/ # lint
mypy src/ # type check
cd docs && make html # build documentation
License
MIT — see LICENSE.
Metadata
Release files for tissage-cosmique 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| tissage_cosmique-0.0.3.tar.gz | 398.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tissage_cosmique-0.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 454.5 kB
Release files / tissage_cosmique-0.0.3.tar.gz
| Download URL | tissage_cosmique-0.0.3.tar.gz |
|---|---|
| Size | 398.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cf3527d37b367a3ea6f389d8f910857c9886a4c248cd178f9a10cdbe3120aeeb
|
|
BLAKE2b-256 checksum How to use checksums |
c14b8330f85e33c2e97e03e1efae0bc9fda689855b8da94adc789459fb06e3da
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 18, 2026.
Transparency logRelease files / tissage_cosmique-0.0.3-py3-none-any.whl
| Download URL | tissage_cosmique-0.0.3-py3-none-any.whl |
|---|---|
| Size | 56.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e206145d9569af9baae9d95627b7cccedb979800673479cb312528eccfd184d3
|
|
BLAKE2b-256 checksum How to use checksums |
a6a1d616ef8fc668dc50269e44f4f004c258159a58bccfc0ee69732056d60343
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 18, 2026.
Transparency log