Skip to main content

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

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 flexability, 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.0.3.tar.gz (18.2 kB view details)

Uploaded Source

Built Distribution

caskade-0.0.3-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for caskade-0.0.3.tar.gz
Algorithm Hash digest
SHA256 22aa3cf9a40853670907fdc5b687c653c6d2bd7caf63772622356e3678525a16
MD5 e6be7905ed712b03a5302fd6513a7d34
BLAKE2b-256 17a688ad54a487ea67306c10dd72a30250da7a41e5185bf7ae70e7910bc30d76

See more details on using hashes here.

File details

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

File metadata

  • Download URL: caskade-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 11.8 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.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c44fe53436ffa84fefdf91e9eab616047a2549f220d8b3478994105410dbd3bd
MD5 8529ae29cb06f514593d0a6e62fdb4bb
BLAKE2b-256 aa1dd219317c840afce42295b3cf8c24e2c329bcc0c1bbbad248e296fe90f2c0

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