Package for building scientific simulators, with dynamic arguments arranged in a directed acyclic graph.
Project description
caskade
Build scientific simulators, treating them as a directed acyclic graph. Handles argument passing for complex nested simulators.
Install
pip install caskade
More details on the docs page.
if you want to use caskade with jax then run:
pip install caskade[jax]
Alternately, just pip install jax/jaxlib separately as they are the only extra requirements.
Usage
Make a Module object which may have some Params. Define a forward method
using the decorator.
from caskade import Module, Param, forward
class MySim(Module):
def __init__(self, a, b=None):
super().__init__()
self.a = a
self.b = Param("b", b)
@forward
def myfun(self, x, b=None):
return x + self.a + b
We may now create instances of the simulator and pass the dynamic parameters.
import torch
sim = MySim(1.0)
params = [torch.tensor(2.0)]
print(sim.myfun(3.0, params=params))
Which will print 6 by automatically filling b with the value from params.
Why do this?
The above example is not very impressive, the real power comes from the fact
that Module objects can be nested, making an arbitrarily complicated
analysis graph. Some other features include:
- Unroll parameters into 1D vector to interface with other packages (emcee, scipy.optimize, dynesty, etc.)
- Link parameters by value or functional relationship
- Reparametrize (e.g. between polar and cartesian) without modifying underlying code
- Save and load sampling chains automatically in HDF5
- Track metadata alongside parameters
- And much more! Beginner tutorial and Advanced tutorial
Use different backends
caskade can be run with different backends for torch, numpy, and jax.
See the Beginners Guide
tutorial
to learn more!
Documentation
The caskade interface has lots of flexibility, check out the
docs to learn more. For a quick start, jump
right to the Jupyter notebook
tutorial!
The caustics package can serve
as a project template utilizing the many features of caskade.
The caskade package maintains 100% coverage for unit testing, ensuring
reliability as the backbone of a research project.
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 caskade-0.14.1.tar.gz.
File metadata
- Download URL: caskade-0.14.1.tar.gz
- Upload date:
- Size: 243.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e9ca6b2bf21c4c0cd6e34743ae05af918acbd4d1fad9c56132c691e175e2b699
|
|
| MD5 |
448d3394f125aef3de966df701412aa6
|
|
| BLAKE2b-256 |
06525902a1642a2d8b37c6eadde4641fe1e219c33760b46ba4c799f1bf98d253
|
Provenance
The following attestation bundles were made for caskade-0.14.1.tar.gz:
Publisher:
cd.yml on ConnorStoneAstro/caskade
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
caskade-0.14.1.tar.gz -
Subject digest:
e9ca6b2bf21c4c0cd6e34743ae05af918acbd4d1fad9c56132c691e175e2b699 - Sigstore transparency entry: 843357475
- Sigstore integration time:
-
Permalink:
ConnorStoneAstro/caskade@430cff6dbde443680373c9b57bdd5fa66132ee81 -
Branch / Tag:
refs/tags/v0.14.1 - Owner: https://github.com/ConnorStoneAstro
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@430cff6dbde443680373c9b57bdd5fa66132ee81 -
Trigger Event:
release
-
Statement type:
File details
Details for the file caskade-0.14.1-py3-none-any.whl.
File metadata
- Download URL: caskade-0.14.1-py3-none-any.whl
- Upload date:
- Size: 27.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7230133a039a6b1dcda18adf02878adb07c657c23bfc71849031ea84a6b12ade
|
|
| MD5 |
47479e81a41e50085352bb207bd0c390
|
|
| BLAKE2b-256 |
dcf3414d8e359f9ef36f28e34dbedd620cbb601aa91050700ac3d88cd778e82a
|
Provenance
The following attestation bundles were made for caskade-0.14.1-py3-none-any.whl:
Publisher:
cd.yml on ConnorStoneAstro/caskade
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
caskade-0.14.1-py3-none-any.whl -
Subject digest:
7230133a039a6b1dcda18adf02878adb07c657c23bfc71849031ea84a6b12ade - Sigstore transparency entry: 843357476
- Sigstore integration time:
-
Permalink:
ConnorStoneAstro/caskade@430cff6dbde443680373c9b57bdd5fa66132ee81 -
Branch / Tag:
refs/tags/v0.14.1 - Owner: https://github.com/ConnorStoneAstro
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@430cff6dbde443680373c9b57bdd5fa66132ee81 -
Trigger Event:
release
-
Statement type: