Skip to main content

Python in a Graph

Why?

My (author) motivation is to be able to generally describe systems that respond to change.

Related (but not the same):

  • reactive programming libraries: Doesn't focus on a 'state'
  • dynamical systems pathsim: This library doesn't, at the face of it, look like it can do what pathsim does, but I think sim descriptions could be mapped somehow.

DAG exec:

  • pipefunc state with no deps. useful as is but you can farm out tasks as you wish.

How?

Rules/functions are repeatedly applied to a 'state' (dict) until there are no more changes. w

1. Specify

Rules initializer:

def __init__(self, state: state = {}, *, log: bool = False): ...

Function registration:

def register(self, argmap: argmap = {}): ...
import state_rules.main as rm

r = rm.Rules({'x':1}, log=True)
@r.register({
    # input
    'x': 'x' # created by default from func sig if not specified
    # output
    'return': 'x', # default is funcname.
    # for multiple outputs,
    # can be a dict that updates state: return: { }
     })
def f(x):
    return x+x # {'x': x+x, 'x+x':x+x } # will be inserted to state

2. Run

The run function signature:

def run(self, maxiter=10, *, stopping: Callable[[state], bool] | None = None): ...
r.run(5)
r.log
[
Iteration(i=0, state={'x': 1})
Iteration(i=1, state={'x': 2})
Iteration(i=2, state={'x': 4})
Iteration(i=3, state={'x': 8})
Iteration(i=4, state={'x': 16})
Iteration(i=5, state={'x': 32})
]

Tips

  • The state is a (flat) dictionary but you can use a fancy dotted dict if you want more structure. Then, use use a function to get at a key.
  • Cache function calls (yourself) as functions will get repeatedly called with the same input.
  • Use stopping critereon to early stop before maxiter.

Release files for pyigr 2026.9.198

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyigr 2026.9.198
File Size Uploaded
pyigr-2026.9.198.tar.gz 9.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyigr 2026.9.198
File Interpreter ABI Platform
pyigr-2026.9.198-py3-none-any.whl Python 3 none any Details

Total release size: 24.0 kB

Release files / pyigr-2026.9.198.tar.gz

Download URL pyigr-2026.9.198.tar.gz
Size 9.9 kB
Tags Source
SHA-256 checksum
How to use checksums
16ca19d2c062794f062d6cc3a1674d1cd8a4fd57b55c41ac427c75afe932bdaa
BLAKE2b-256 checksum
How to use checksums
3a47a29e66245b61102c3661129ae50e325b1c4ab52133345a6a9020fb9eed3d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.

Transparency log

Release files / pyigr-2026.9.198-py3-none-any.whl

Download URL pyigr-2026.9.198-py3-none-any.whl
Size 14.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
684538effa3cfc25998f749c13ff3a12d4a9d3b8c554fd10cb12922427953d1a
BLAKE2b-256 checksum
How to use checksums
a5b38a911964b9cf8fbf07e8de1cf7a9b5f0826b7f3f9bfd041b1cd61c8eae39
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

2026.9.198 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page