{"id":16516956,"url":"https://github.com/alkasm/timingdiagram","last_synced_at":"2025-03-02T18:19:44.630Z","repository":{"id":57475663,"uuid":"202973919","full_name":"alkasm/timingdiagram","owner":"alkasm","description":"Temporal boolean algebra","archived":false,"fork":false,"pushed_at":"2020-03-30T01:34:27.000Z","size":39,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-13T12:15:53.693Z","etag":null,"topics":["data-structures"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alkasm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-08-18T07:34:40.000Z","updated_at":"2020-03-30T01:34:29.000Z","dependencies_parsed_at":"2022-09-07T13:51:24.622Z","dependency_job_id":null,"html_url":"https://github.com/alkasm/timingdiagram","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alkasm%2Ftimingdiagram","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alkasm%2Ftimingdiagram/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alkasm%2Ftimingdiagram/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alkasm%2Ftimingdiagram/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alkasm","download_url":"https://codeload.github.com/alkasm/timingdiagram/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241549145,"owners_count":19980481,"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":["data-structures"],"created_at":"2024-10-11T16:27:50.613Z","updated_at":"2025-03-02T18:19:44.602Z","avatar_url":"https://github.com/alkasm.png","language":"Python","readme":"# timingdiagram\n\n\u003cimg src=\"https://raw.githubusercontent.com/alkasm/timingdiagram/master/timingdiagram.svg?sanitize=true\" alt=\"Visual timing diagram example\" width=\"100%\"\u003e\n\nWork with discrete state changes over time.\n\n* Reduce data to state changes\n* Compare diagrams over time\n* Query state by time\n* Use any ordered index\n\n## Install\n\nFrom PyPI with `pip`:\n\n```sh\npip install timingdiagram-alkasm\n```\n\nFrom source:\n\n```sh\ngit clone https://github.com/alkasm/timingdiagram\ncd timingdiagram\npip install .\n```\n\nNote that you must have `pip \u003e= 19.0` installed in your environment to install from source, since this project uses the `pyproject.toml` file defined in [PEP-0517](https://www.python.org/dev/peps/pep-0517/) instead of `setup.py`. More from PyPA [here](https://pip.pypa.io/en/stable/reference/pip/#pep-517-and-518-support).\n\n\n## Try it out\n\n```python\n\u003e\u003e\u003e from timingdiagram import TimingDiagram\n\u003e\u003e\u003e d1 = TimingDiagram(enumerate([False, False, False, True, True, False, True]))\n\u003e\u003e\u003e d2 = TimingDiagram(enumerate([False, True, False, False, True, False, False]))\n\u003e\u003e\u003e d1 | d2\nTimingDiagram([(0, False), (1, True), (2, False), (3, True), (5, False), (6, True)])\n```\n\n## Example\n\nSuppose you had a log of users signing in and out of a service, and the log included the time, user id, and action the user took. We can view each user's login/logout history as a timing diagram, and simply `\u0026` them all together to see when all users were logged in at the same time:\n\n```python\nlog = \"\"\"\\\n2019-08-27T19:38:50 001768bf-af44-46a6-890d-048f2c50aa29 login\n2019-08-27T19:51:11 084c07f0-dd0d-46a3-8eb5-1d4cb13756a4 logout\n2019-08-27T19:55:25 001768bf-af44-46a6-890d-048f2c50aa29 logout\n2019-08-27T19:58:37 001768bf-af44-46a6-890d-048f2c50aa29 login\n2019-08-27T20:17:21 a8118353-eb81-4ce0-8d10-6f3f9de6d7ca login\n2019-08-27T20:45:19 001768bf-af44-46a6-890d-048f2c50aa29 logout\n2019-08-27T21:01:45 001768bf-af44-46a6-890d-048f2c50aa29 login\n2019-08-27T21:18:09 001768bf-af44-46a6-890d-048f2c50aa29 logout\n2019-08-27T22:02:37 084c07f0-dd0d-46a3-8eb5-1d4cb13756a4 login\n2019-08-27T22:55:54 001768bf-af44-46a6-890d-048f2c50aa29 login\n2019-08-27T23:08:07 001768bf-af44-46a6-890d-048f2c50aa29 logout\n2019-08-27T23:23:04 a8118353-eb81-4ce0-8d10-6f3f9de6d7ca logout\n2019-08-27T23:47:50 001768bf-af44-46a6-890d-048f2c50aa29 login\n2019-08-27T23:55:10 084c07f0-dd0d-46a3-8eb5-1d4cb13756a4 logout\n2019-08-27T23:56:33 001768bf-af44-46a6-890d-048f2c50aa29 logout\\\n\"\"\".split(\"\\n\")\n\n\nfrom collections import defaultdict\nfrom functools import reduce\nfrom timingdiagram import TimingDiagram\n\n\nsessions = defaultdict(list)\nfor row in log:\n    ts, userid, action = row.split()\n    sessions[userid].append((ts, action == \"login\"))\n\nall_logged_in = reduce(lambda d1, d2: d1 \u0026 d2, map(TimingDiagram, sessions.values()))\n```\n\nFrom just a few lines of code, we get a timing diagram corresponding to when all the users were logged in:\n\n```python\nTimingDiagram([\n  ('2019-08-27T19:38:50', False), \n  ('2019-08-27T22:55:54', True), \n  ('2019-08-27T23:08:07', False), \n  ('2019-08-27T23:56:33', False)\n ])\n ```\n \nSo all users were logged in between `22:55:54` and `23:08:07` on `2019-08-27`. The additional states at the beginning and end signify the start and end times of the logs.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falkasm%2Ftimingdiagram","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falkasm%2Ftimingdiagram","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falkasm%2Ftimingdiagram/lists"}