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
stoppingcritereon to early stop beforemaxiter.
Release files for pyigr 2026.9.191
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyigr-2026.9.191.tar.gz | 9.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyigr-2026.9.191-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 23.0 kB
Release files / pyigr-2026.9.191.tar.gz
| Download URL | pyigr-2026.9.191.tar.gz |
|---|---|
| Size | 9.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5e515a9b440eb1220e7b3a7403f38e1d878cea2f59b5632d06ebd993ad4d4235
|
|
BLAKE2b-256 checksum How to use checksums |
732df2d1740117d62d52ce7e10c7be59c65f4fd106677c164b6976d0414a32c2
|
| 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 25, 2026.
Transparency logRelease files / pyigr-2026.9.191-py3-none-any.whl
| Download URL | pyigr-2026.9.191-py3-none-any.whl |
|---|---|
| Size | 13.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d236f141c43d555e6b9d20bd2ac88e66f5daef8e8d16af2a2a04953972aa1f92
|
|
BLAKE2b-256 checksum How to use checksums |
a5a7074741eb87dbfc28ecdb9dc50cf42ef27dccd0d0b86c2b47b88e5e1a14f0
|
| 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 25, 2026.
Transparency log