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

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.

Tutorial

The caskade interface has lots of flexibility, check out the Jupyter notebook tutorial to learn how to use it!

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.1.0.tar.gz (18.9 kB view details)

Uploaded Source

Built Distribution

caskade-0.1.0-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for caskade-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6c9fb10b31c93477fcc1c547669f99e17fa2c4327b6ee864f56973adfa641e52
MD5 d1e0e2fc7d845b7d7868783670793d13
BLAKE2b-256 7a58ef370e5b6adffd9d0961020b72211cc46c873fcdf3229ba84b0459bf0cdf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: caskade-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.3 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6fb928269136203adfeeb5b75d09a23c0c8d4e3b20004a4d1c391bf402375cd7
MD5 32e90880f7413ac9b5c63953b0d817e6
BLAKE2b-256 3416fffc6598ac5d6f98b8b366f3d7f4c77a1c56844be61a6ff7049c15d39a01

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