Skip to main content

Package for building scientific simulators, with dynamic arguments arranged in a directed acyclic graph.

Project description

caskade logo

caskade

CI CD codecov PyPI - Version Documentation Status DOI

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


Download files

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

Source Distribution

caskade-0.12.0.tar.gz (243.2 kB view details)

Uploaded Source

Built Distribution

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

caskade-0.12.0-py3-none-any.whl (26.7 kB view details)

Uploaded Python 3

File details

Details for the file caskade-0.12.0.tar.gz.

File metadata

  • Download URL: caskade-0.12.0.tar.gz
  • Upload date:
  • Size: 243.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for caskade-0.12.0.tar.gz
Algorithm Hash digest
SHA256 ee56e12bb343d7ffb2bc1230348bea40f82ae90cfa198392e790a8323bbebe91
MD5 4c55ebecfaaf2df5e09f6d0ff39558d7
BLAKE2b-256 3020638db0e547354759e0ab315718bf3f6c61b6dca0683f8d1dec5c460aca67

See more details on using hashes here.

Provenance

The following attestation bundles were made for caskade-0.12.0.tar.gz:

Publisher: cd.yml on ConnorStoneAstro/caskade

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

File details

Details for the file caskade-0.12.0-py3-none-any.whl.

File metadata

  • Download URL: caskade-0.12.0-py3-none-any.whl
  • Upload date:
  • Size: 26.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for caskade-0.12.0-py3-none-any.whl
Algorithm Hash digest
SHA256 85b97c431649569fed661c484218aafc4e4f79da47c5fe86974bfac561475a59
MD5 3e3765a4605c0985825b6b7f51626f29
BLAKE2b-256 d6939cf3682879f96bb2ab643c19c1005c97e2d2e0b6855bf979916a75c4b49f

See more details on using hashes here.

Provenance

The following attestation bundles were made for caskade-0.12.0-py3-none-any.whl:

Publisher: cd.yml on ConnorStoneAstro/caskade

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

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page