{"id":29585728,"url":"https://github.com/hendrixstring/secret_exercise","last_synced_at":"2025-07-20T02:16:41.334Z","repository":{"id":193193857,"uuid":"688058898","full_name":"HendrixString/secret_exercise","owner":"HendrixString","description":null,"archived":false,"fork":false,"pushed_at":"2023-09-07T04:49:28.000Z","size":1,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2023-09-07T05:45:14.876Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HendrixString.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-09-06T15:04:52.000Z","updated_at":"2023-09-07T05:45:24.717Z","dependencies_parsed_at":"2023-09-07T05:45:22.775Z","dependency_job_id":null,"html_url":"https://github.com/HendrixString/secret_exercise","commit_stats":null,"previous_names":["hendrixstring/secret_exercise"],"tags_count":null,"template":null,"template_full_name":null,"purl":"pkg:github/HendrixString/secret_exercise","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HendrixString%2Fsecret_exercise","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HendrixString%2Fsecret_exercise/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HendrixString%2Fsecret_exercise/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HendrixString%2Fsecret_exercise/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HendrixString","download_url":"https://codeload.github.com/HendrixString/secret_exercise/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HendrixString%2Fsecret_exercise/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266057350,"owners_count":23870131,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-07-20T02:16:37.590Z","updated_at":"2025-07-20T02:16:41.319Z","avatar_url":"https://github.com/HendrixString.png","language":"Jupyter Notebook","readme":"# State Machine Framework\nAn experiement with state machine modeling\n\n\u003cimg src=\"sm.jpeg\" height=\"400px\"\u003e\n\n## install\n`pip3 install -e .`\n\n## run test\n`python3 -m unittest tests.test_machine`\n\n## Usage \n\n- **States** and **Events** can be any object.\n- If state is a `callable` object, then it will be triggered to call side effects.\n- You use states as nodes and events as edges.\n\nUse the `add(from_state: object, event: object, to_state: object)` method of `Machine` class to model the state machine.\n\n\n```python\nfrom machine.machine import Machine\n\nm = Machine(\"Start\")\n\nm.add(\"Start\", \"red\", \"R1\") \\\n .add(\"Start\", \"yellow\", \"Y1\") \\\n .add(\"R1\", \"red\", \"R2\") \\\n .add(\"R1\", \"yellow\", \"Y1\") \\\n .add(\"R2\", \"red\", \"R3\") \\\n .add(\"R2\", \"yellow\", \"Y1\") \\\n .add(\"R3\", \"red\", \"R4\") \\\n .add(\"R3\", \"yellow\", \"Y1\") \\\n .add(\"R4\", \"red\", \"R4\") \\\n .add(\"R4\", \"yellow\", \"Y1\") \\\n .add(\"Y1\", \"red\", \"R1\") \\\n .add(\"Y1\", \"yellow\", \"Y2\") \\\n .add(\"Y2\", \"red\", \"R1\") \\\n .add(\"Y2\", \"yellow\", \"Y3\") \\\n .add(\"Y3\", \"red\", \"R1\") \\\n .add(\"Y3\", \"yellow\", \"Y4\") \\\n .add(\"Y4\", \"red\", \"R1\") \\\n .add(\"Y4\", \"yellow\", \"Y4\")\n```\n\nThen, you can iterate a list of events with\n\n```python\nfor state in m.iterate_input(['red', 'yellow', 'red', 'yellow', 'red', 'yellow', 'red', 'yellow']):\n    print(state)\n\n# prints: R1, Y1, R1, Y1, R1, Y1, R1, Y1\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhendrixstring%2Fsecret_exercise","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhendrixstring%2Fsecret_exercise","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhendrixstring%2Fsecret_exercise/lists"}