Skip to main content

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

Project description

caskade

CI CD codecov PyPI - Version Documentation Status

Build scientific simulators, treating them as a directed acyclic graph. Handles argument passing for complex nested simulators.

Install

pip install caskade

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 arbitrarily making a much more complicated analysis graph. Further, the Param objects can be linked or have other complex relationships. All of the complexity of the nested structure and argument passing is abstracted away so that at the top one need only pass a list of tensors for each parameter, a single large 1d tensor, or a dictionary with the same structure as the graph.

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!

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.2.0.tar.gz (2.0 MB view details)

Uploaded Source

Built Distribution

caskade-0.2.0-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: caskade-0.2.0.tar.gz
  • Upload date:
  • Size: 2.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for caskade-0.2.0.tar.gz
Algorithm Hash digest
SHA256 fd6b472e4a95e47202e480d9db8c2215ef9a921e602703d11cc4499bd59128ea
MD5 879543e892091d026e1f443dc0688633
BLAKE2b-256 1926b4d9d35c273966279920662111e4634024f671f6ece5a1cf11b2baddb528

See more details on using hashes here.

File details

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

File metadata

  • Download URL: caskade-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 13.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for caskade-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 831685456ddb5deb6e4f900ec7c00cae27e3dcdd5cfa77e67247c9c83a284e62
MD5 8a04c9e035b4b77bef16bbe537c76cae
BLAKE2b-256 a5c578ac9c34744b82b35e0ce6f29584c02d23f8ec4480b24b92f4f3834c3191

See more details on using hashes here.

Supported by

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