Skip to main content

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.

How?

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

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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

state_rules-2026.9.50.tar.gz (2.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

state_rules-2026.9.50-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file state_rules-2026.9.50.tar.gz.

File metadata

  • Download URL: state_rules-2026.9.50.tar.gz
  • Upload date:
  • Size: 2.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for state_rules-2026.9.50.tar.gz
Algorithm Hash digest
SHA256 273cc5b32ac8f4d2c1d2b86f8db1c831c383c3f1e5160a0686def20a54f8854d
MD5 99bac6dae7dc3c1fe5896aa133e4003d
BLAKE2b-256 84a43f6d7306349a32fbca3529cee0e2a863c8035ec7babd4078eb503c730b2b

See more details on using hashes here.

Provenance

The following attestation bundles were made for state_rules-2026.9.50.tar.gz:

Publisher: python-publish.yaml on majidaldo/state-rules

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file state_rules-2026.9.50-py3-none-any.whl.

File metadata

File hashes

Hashes for state_rules-2026.9.50-py3-none-any.whl
Algorithm Hash digest
SHA256 58ad0c11cf0e944800f8297fb5e9077b547e0f51c6d3aefb7cb36914611e0cd3
MD5 0f601e5262fb9392e01ed15a6f037285
BLAKE2b-256 58df65682d0d7d45c93091d31f691a938f094c4e6997429ee7f15d6fadead31c

See more details on using hashes here.

Provenance

The following attestation bundles were made for state_rules-2026.9.50-py3-none-any.whl:

Publisher: python-publish.yaml on majidaldo/state-rules

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

2026.9.50 This release

2 files

2026.8.48

2 files

2026.8.43

2 files

2026.8.37

2 files

2026.3.35

2 files

2026.3.34

2 files

2026.3.33

2 files

2026.3.29

2 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