anihmm 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- anihmm-0.1.0/LICENSE +21 -0
- anihmm-0.1.0/PKG-INFO +166 -0
- anihmm-0.1.0/README.md +139 -0
- anihmm-0.1.0/pyproject.toml +94 -0
- anihmm-0.1.0/pyproject.toml.orig +97 -0
- anihmm-0.1.0/src/anihmm/__init__.py +52 -0
- anihmm-0.1.0/src/anihmm/_nodes.py +24 -0
- anihmm-0.1.0/src/anihmm/_symbols.py +13 -0
- anihmm-0.1.0/src/anihmm/_validation.py +32 -0
- anihmm-0.1.0/src/anihmm/exceptions.py +42 -0
- anihmm-0.1.0/src/anihmm/models.py +85 -0
- anihmm-0.1.0/src/anihmm/playback/__init__.py +28 -0
- anihmm-0.1.0/src/anihmm/playback/engine.py +190 -0
- anihmm-0.1.0/src/anihmm/playback/helpers.py +47 -0
- anihmm-0.1.0/src/anihmm/playback/options.py +156 -0
- anihmm-0.1.0/src/anihmm/playback/progress.py +390 -0
- anihmm-0.1.0/src/anihmm/playback/session.py +228 -0
- anihmm-0.1.0/src/anihmm/presets/__init__.py +22 -0
- anihmm-0.1.0/src/anihmm/presets/demo.py +22 -0
- anihmm-0.1.0/src/anihmm/presets/random.py +262 -0
- anihmm-0.1.0/src/anihmm/py.typed +1 -0
- anihmm-0.1.0/src/anihmm/render/__init__.py +15 -0
- anihmm-0.1.0/src/anihmm/render/emissions.py +127 -0
- anihmm-0.1.0/src/anihmm/render/geometry.py +157 -0
- anihmm-0.1.0/src/anihmm/render/lattice.py +114 -0
- anihmm-0.1.0/src/anihmm/render/rows.py +213 -0
- anihmm-0.1.0/src/anihmm/sequence/__init__.py +13 -0
- anihmm-0.1.0/src/anihmm/sequence/builder.py +324 -0
- anihmm-0.1.0/src/anihmm/sequence/compiler.py +176 -0
anihmm-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Leighton Payne
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
anihmm-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: anihmm
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Rich terminal HMM animation library for embedded loading and progress displays.
|
|
5
|
+
Keywords: animation,terminal,rich,hmm,api,asyncio
|
|
6
|
+
Author: Leighton Payne
|
|
7
|
+
Author-email: Leighton Payne <leightonpayne98@gmail.com>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Environment :: Console
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
+
Classifier: Topic :: Terminals
|
|
21
|
+
Requires-Dist: rich>=14.3.3
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Project-URL: Homepage, https://leightonpayne.github.io/anihmm
|
|
24
|
+
Project-URL: Repository, https://github.com/leightonpayne/anihmm
|
|
25
|
+
Project-URL: Documentation, https://leightonpayne.github.io/anihmm
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# anihmm
|
|
29
|
+
|
|
30
|
+
`anihmm` draws small HMM-style animations in a terminal. Use it as a loading
|
|
31
|
+
indicator, build a custom state path, or render individual frames with
|
|
32
|
+
[Rich](https://github.com/Textualize/rich).
|
|
33
|
+
|
|
34
|
+
<img
|
|
35
|
+
src="https://raw.githubusercontent.com/leightonpayne/anihmm/main/docs/assets/anihmm-demo.gif"
|
|
36
|
+
alt="Terminal animation progressing through an HMM path"
|
|
37
|
+
width="100%"
|
|
38
|
+
>
|
|
39
|
+
|
|
40
|
+
## Install
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip install anihmm
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Python 3.10 or newer is required.
|
|
47
|
+
|
|
48
|
+
## Use
|
|
49
|
+
|
|
50
|
+
Wrap the work you want to animate:
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
from anihmm import ProcessingOptions, processing_animation
|
|
54
|
+
|
|
55
|
+
with processing_animation(ProcessingOptions.random()):
|
|
56
|
+
run_your_work()
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
The animation runs in the background and stops when the block exits. When
|
|
60
|
+
output is redirected or captured, `anihmm` stays quiet automatically.
|
|
61
|
+
|
|
62
|
+
When the work finishes, you can replace the animation with a final frame and
|
|
63
|
+
print the results:
|
|
64
|
+
|
|
65
|
+
<img
|
|
66
|
+
src="https://raw.githubusercontent.com/leightonpayne/anihmm/main/docs/assets/processing-results.gif"
|
|
67
|
+
alt="Processing animation handing off to HMM result counts"
|
|
68
|
+
width="100%"
|
|
69
|
+
>
|
|
70
|
+
|
|
71
|
+
To show fixed text on a random path:
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
with processing_animation(
|
|
75
|
+
ProcessingOptions.random(emissions="SEARCHING", seed=7)
|
|
76
|
+
):
|
|
77
|
+
run_your_work()
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Async code uses the matching context manager:
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
from anihmm import ProcessingOptions, async_processing_animation
|
|
84
|
+
|
|
85
|
+
async with async_processing_animation(ProcessingOptions.random()):
|
|
86
|
+
await run_your_work()
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Advance a predetermined path as individual units of work complete:
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
from anihmm import progress_animation
|
|
93
|
+
|
|
94
|
+
with progress_animation(columns=3) as progress:
|
|
95
|
+
for state, emission in (("M", "A"), ("D", None), ("M", "C")):
|
|
96
|
+
run_one_step()
|
|
97
|
+
progress.advance(state, emission=emission)
|
|
98
|
+
progress.finish()
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
<img
|
|
102
|
+
src="https://raw.githubusercontent.com/leightonpayne/anihmm/main/docs/assets/progress-indicator.gif"
|
|
103
|
+
alt="Work advancing a predetermined HMM path"
|
|
104
|
+
width="100%"
|
|
105
|
+
>
|
|
106
|
+
|
|
107
|
+
## Build a sequence
|
|
108
|
+
|
|
109
|
+
Use `HMMSequence` when a preset is not enough:
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
from anihmm import HMMSequence, compile_steps
|
|
113
|
+
|
|
114
|
+
sequence = HMMSequence()
|
|
115
|
+
for symbol in "SEARCH":
|
|
116
|
+
sequence.settle("M")
|
|
117
|
+
sequence.emit(symbol)
|
|
118
|
+
sequence.finish()
|
|
119
|
+
|
|
120
|
+
frames = compile_steps(sequence.build())
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## More examples
|
|
124
|
+
|
|
125
|
+
Generate an exact number of random emissions:
|
|
126
|
+
|
|
127
|
+
<img
|
|
128
|
+
src="https://raw.githubusercontent.com/leightonpayne/anihmm/main/docs/assets/random-emissions.gif"
|
|
129
|
+
alt="Random amino-acid emissions"
|
|
130
|
+
width="100%"
|
|
131
|
+
>
|
|
132
|
+
|
|
133
|
+
Keep fixed text while generating a different path on each loop:
|
|
134
|
+
|
|
135
|
+
<img
|
|
136
|
+
src="https://raw.githubusercontent.com/leightonpayne/anihmm/main/docs/assets/changing-paths.gif"
|
|
137
|
+
alt="WAITING emitted on changing random paths"
|
|
138
|
+
width="100%"
|
|
139
|
+
>
|
|
140
|
+
|
|
141
|
+
Complete the unused columns of a bounded sequence with deletion states:
|
|
142
|
+
|
|
143
|
+
<img
|
|
144
|
+
src="https://raw.githubusercontent.com/leightonpayne/anihmm/main/docs/assets/delete-completion.gif"
|
|
145
|
+
alt="Automatic deletion-state completion"
|
|
146
|
+
width="100%"
|
|
147
|
+
>
|
|
148
|
+
|
|
149
|
+
Preview every possible transition before settling on one:
|
|
150
|
+
|
|
151
|
+
<img
|
|
152
|
+
src="https://raw.githubusercontent.com/leightonpayne/anihmm/main/docs/assets/transition-previews.gif"
|
|
153
|
+
alt="Candidate transition previews"
|
|
154
|
+
width="100%"
|
|
155
|
+
>
|
|
156
|
+
|
|
157
|
+
The runnable versions are in
|
|
158
|
+
[`examples/`](https://github.com/leightonpayne/anihmm/tree/main/examples/), with explanations in
|
|
159
|
+
the [examples guide](https://leightonpayne.github.io/anihmm/usage/example/).
|
|
160
|
+
|
|
161
|
+
## Documentation
|
|
162
|
+
|
|
163
|
+
- [Quickstart](https://leightonpayne.github.io/anihmm/usage/quickstart/)
|
|
164
|
+
- [Examples](https://leightonpayne.github.io/anihmm/usage/example/)
|
|
165
|
+
- [Python API guide](https://leightonpayne.github.io/anihmm/usage/inputs/)
|
|
166
|
+
- [API reference](https://leightonpayne.github.io/anihmm/reference/)
|
anihmm-0.1.0/README.md
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# anihmm
|
|
2
|
+
|
|
3
|
+
`anihmm` draws small HMM-style animations in a terminal. Use it as a loading
|
|
4
|
+
indicator, build a custom state path, or render individual frames with
|
|
5
|
+
[Rich](https://github.com/Textualize/rich).
|
|
6
|
+
|
|
7
|
+
<img
|
|
8
|
+
src="https://raw.githubusercontent.com/leightonpayne/anihmm/main/docs/assets/anihmm-demo.gif"
|
|
9
|
+
alt="Terminal animation progressing through an HMM path"
|
|
10
|
+
width="100%"
|
|
11
|
+
>
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pip install anihmm
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Python 3.10 or newer is required.
|
|
20
|
+
|
|
21
|
+
## Use
|
|
22
|
+
|
|
23
|
+
Wrap the work you want to animate:
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
from anihmm import ProcessingOptions, processing_animation
|
|
27
|
+
|
|
28
|
+
with processing_animation(ProcessingOptions.random()):
|
|
29
|
+
run_your_work()
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
The animation runs in the background and stops when the block exits. When
|
|
33
|
+
output is redirected or captured, `anihmm` stays quiet automatically.
|
|
34
|
+
|
|
35
|
+
When the work finishes, you can replace the animation with a final frame and
|
|
36
|
+
print the results:
|
|
37
|
+
|
|
38
|
+
<img
|
|
39
|
+
src="https://raw.githubusercontent.com/leightonpayne/anihmm/main/docs/assets/processing-results.gif"
|
|
40
|
+
alt="Processing animation handing off to HMM result counts"
|
|
41
|
+
width="100%"
|
|
42
|
+
>
|
|
43
|
+
|
|
44
|
+
To show fixed text on a random path:
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
with processing_animation(
|
|
48
|
+
ProcessingOptions.random(emissions="SEARCHING", seed=7)
|
|
49
|
+
):
|
|
50
|
+
run_your_work()
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Async code uses the matching context manager:
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
from anihmm import ProcessingOptions, async_processing_animation
|
|
57
|
+
|
|
58
|
+
async with async_processing_animation(ProcessingOptions.random()):
|
|
59
|
+
await run_your_work()
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Advance a predetermined path as individual units of work complete:
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
from anihmm import progress_animation
|
|
66
|
+
|
|
67
|
+
with progress_animation(columns=3) as progress:
|
|
68
|
+
for state, emission in (("M", "A"), ("D", None), ("M", "C")):
|
|
69
|
+
run_one_step()
|
|
70
|
+
progress.advance(state, emission=emission)
|
|
71
|
+
progress.finish()
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
<img
|
|
75
|
+
src="https://raw.githubusercontent.com/leightonpayne/anihmm/main/docs/assets/progress-indicator.gif"
|
|
76
|
+
alt="Work advancing a predetermined HMM path"
|
|
77
|
+
width="100%"
|
|
78
|
+
>
|
|
79
|
+
|
|
80
|
+
## Build a sequence
|
|
81
|
+
|
|
82
|
+
Use `HMMSequence` when a preset is not enough:
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
from anihmm import HMMSequence, compile_steps
|
|
86
|
+
|
|
87
|
+
sequence = HMMSequence()
|
|
88
|
+
for symbol in "SEARCH":
|
|
89
|
+
sequence.settle("M")
|
|
90
|
+
sequence.emit(symbol)
|
|
91
|
+
sequence.finish()
|
|
92
|
+
|
|
93
|
+
frames = compile_steps(sequence.build())
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## More examples
|
|
97
|
+
|
|
98
|
+
Generate an exact number of random emissions:
|
|
99
|
+
|
|
100
|
+
<img
|
|
101
|
+
src="https://raw.githubusercontent.com/leightonpayne/anihmm/main/docs/assets/random-emissions.gif"
|
|
102
|
+
alt="Random amino-acid emissions"
|
|
103
|
+
width="100%"
|
|
104
|
+
>
|
|
105
|
+
|
|
106
|
+
Keep fixed text while generating a different path on each loop:
|
|
107
|
+
|
|
108
|
+
<img
|
|
109
|
+
src="https://raw.githubusercontent.com/leightonpayne/anihmm/main/docs/assets/changing-paths.gif"
|
|
110
|
+
alt="WAITING emitted on changing random paths"
|
|
111
|
+
width="100%"
|
|
112
|
+
>
|
|
113
|
+
|
|
114
|
+
Complete the unused columns of a bounded sequence with deletion states:
|
|
115
|
+
|
|
116
|
+
<img
|
|
117
|
+
src="https://raw.githubusercontent.com/leightonpayne/anihmm/main/docs/assets/delete-completion.gif"
|
|
118
|
+
alt="Automatic deletion-state completion"
|
|
119
|
+
width="100%"
|
|
120
|
+
>
|
|
121
|
+
|
|
122
|
+
Preview every possible transition before settling on one:
|
|
123
|
+
|
|
124
|
+
<img
|
|
125
|
+
src="https://raw.githubusercontent.com/leightonpayne/anihmm/main/docs/assets/transition-previews.gif"
|
|
126
|
+
alt="Candidate transition previews"
|
|
127
|
+
width="100%"
|
|
128
|
+
>
|
|
129
|
+
|
|
130
|
+
The runnable versions are in
|
|
131
|
+
[`examples/`](https://github.com/leightonpayne/anihmm/tree/main/examples/), with explanations in
|
|
132
|
+
the [examples guide](https://leightonpayne.github.io/anihmm/usage/example/).
|
|
133
|
+
|
|
134
|
+
## Documentation
|
|
135
|
+
|
|
136
|
+
- [Quickstart](https://leightonpayne.github.io/anihmm/usage/quickstart/)
|
|
137
|
+
- [Examples](https://leightonpayne.github.io/anihmm/usage/example/)
|
|
138
|
+
- [Python API guide](https://leightonpayne.github.io/anihmm/usage/inputs/)
|
|
139
|
+
- [API reference](https://leightonpayne.github.io/anihmm/reference/)
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "anihmm"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Rich terminal HMM animation library for embedded loading and progress displays."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
requires-python = ">=3.10"
|
|
9
|
+
keywords = [
|
|
10
|
+
"animation",
|
|
11
|
+
"terminal",
|
|
12
|
+
"rich",
|
|
13
|
+
"hmm",
|
|
14
|
+
"api",
|
|
15
|
+
"asyncio",
|
|
16
|
+
]
|
|
17
|
+
classifiers = [
|
|
18
|
+
"Development Status :: 3 - Alpha",
|
|
19
|
+
"Environment :: Console",
|
|
20
|
+
"Intended Audience :: Developers",
|
|
21
|
+
"Programming Language :: Python :: 3",
|
|
22
|
+
"Programming Language :: Python :: 3.10",
|
|
23
|
+
"Programming Language :: Python :: 3.11",
|
|
24
|
+
"Programming Language :: Python :: 3.12",
|
|
25
|
+
"Programming Language :: Python :: 3.13",
|
|
26
|
+
"Programming Language :: Python :: 3.14",
|
|
27
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
28
|
+
"Topic :: Terminals",
|
|
29
|
+
]
|
|
30
|
+
dependencies = ["rich>=14.3.3"]
|
|
31
|
+
|
|
32
|
+
[[project.authors]]
|
|
33
|
+
name = "Leighton Payne"
|
|
34
|
+
email = "leightonpayne98@gmail.com"
|
|
35
|
+
|
|
36
|
+
[project.urls]
|
|
37
|
+
Homepage = "https://leightonpayne.github.io/anihmm"
|
|
38
|
+
Repository = "https://github.com/leightonpayne/anihmm"
|
|
39
|
+
Documentation = "https://leightonpayne.github.io/anihmm"
|
|
40
|
+
|
|
41
|
+
[build-system]
|
|
42
|
+
requires = ["uv_build>=0.9.6,<0.12.0"]
|
|
43
|
+
build-backend = "uv_build"
|
|
44
|
+
|
|
45
|
+
[dependency-groups]
|
|
46
|
+
test = [
|
|
47
|
+
"pytest>=8.3.0",
|
|
48
|
+
"pytest-cov>=5.0.0",
|
|
49
|
+
]
|
|
50
|
+
dev = [
|
|
51
|
+
{ include-group = "test" },
|
|
52
|
+
"pip-audit>=2.10.1",
|
|
53
|
+
"pillow>=13.0.0",
|
|
54
|
+
"pyright>=1.1.390",
|
|
55
|
+
"ruff>=0.8.0",
|
|
56
|
+
"rumdl>=0.2.52",
|
|
57
|
+
]
|
|
58
|
+
docs = [
|
|
59
|
+
"flexoki-zensical>=0.1.1",
|
|
60
|
+
"mkdocs-material>=9.7.7",
|
|
61
|
+
"mkdocstrings[python]>=1.0.4",
|
|
62
|
+
"pymdown-extensions>=11.0.1",
|
|
63
|
+
"zensical>=0.0.43",
|
|
64
|
+
]
|
|
65
|
+
|
|
66
|
+
[tool.uv.dependency-groups.dev]
|
|
67
|
+
requires-python = ">=3.11"
|
|
68
|
+
|
|
69
|
+
[tool.pytest.ini_options]
|
|
70
|
+
testpaths = ["tests"]
|
|
71
|
+
pythonpath = ["src"]
|
|
72
|
+
addopts = ["-ra"]
|
|
73
|
+
|
|
74
|
+
[tool.ruff]
|
|
75
|
+
target-version = "py310"
|
|
76
|
+
line-length = 100
|
|
77
|
+
|
|
78
|
+
[tool.ruff.lint]
|
|
79
|
+
select = [
|
|
80
|
+
"E",
|
|
81
|
+
"F",
|
|
82
|
+
"I",
|
|
83
|
+
"B",
|
|
84
|
+
"UP",
|
|
85
|
+
]
|
|
86
|
+
|
|
87
|
+
[tool.ruff.format]
|
|
88
|
+
quote-style = "double"
|
|
89
|
+
indent-style = "space"
|
|
90
|
+
|
|
91
|
+
[tool.pyright]
|
|
92
|
+
pythonVersion = "3.10"
|
|
93
|
+
include = ["src"]
|
|
94
|
+
typeCheckingMode = "standard"
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "anihmm"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Rich terminal HMM animation library for embedded loading and progress displays."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
authors = [
|
|
9
|
+
{ name = "Leighton Payne", email = "leightonpayne98@gmail.com" }
|
|
10
|
+
]
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
keywords = [
|
|
13
|
+
"animation",
|
|
14
|
+
"terminal",
|
|
15
|
+
"rich",
|
|
16
|
+
"hmm",
|
|
17
|
+
"api",
|
|
18
|
+
"asyncio",
|
|
19
|
+
]
|
|
20
|
+
classifiers = [
|
|
21
|
+
"Development Status :: 3 - Alpha",
|
|
22
|
+
"Environment :: Console",
|
|
23
|
+
"Intended Audience :: Developers",
|
|
24
|
+
"Programming Language :: Python :: 3",
|
|
25
|
+
"Programming Language :: Python :: 3.10",
|
|
26
|
+
"Programming Language :: Python :: 3.11",
|
|
27
|
+
"Programming Language :: Python :: 3.12",
|
|
28
|
+
"Programming Language :: Python :: 3.13",
|
|
29
|
+
"Programming Language :: Python :: 3.14",
|
|
30
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
31
|
+
"Topic :: Terminals",
|
|
32
|
+
]
|
|
33
|
+
dependencies = [
|
|
34
|
+
"rich>=14.3.3",
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
[project.urls]
|
|
38
|
+
Homepage = "https://leightonpayne.github.io/anihmm"
|
|
39
|
+
Repository = "https://github.com/leightonpayne/anihmm"
|
|
40
|
+
Documentation = "https://leightonpayne.github.io/anihmm"
|
|
41
|
+
|
|
42
|
+
[build-system]
|
|
43
|
+
requires = ["uv_build>=0.9.6,<0.12.0"]
|
|
44
|
+
build-backend = "uv_build"
|
|
45
|
+
|
|
46
|
+
[dependency-groups]
|
|
47
|
+
test = [
|
|
48
|
+
"pytest>=8.3.0",
|
|
49
|
+
"pytest-cov>=5.0.0",
|
|
50
|
+
]
|
|
51
|
+
dev = [
|
|
52
|
+
{ include-group = "test" },
|
|
53
|
+
"pip-audit>=2.10.1",
|
|
54
|
+
"pillow>=13.0.0",
|
|
55
|
+
"pyright>=1.1.390",
|
|
56
|
+
"ruff>=0.8.0",
|
|
57
|
+
"rumdl>=0.2.52",
|
|
58
|
+
]
|
|
59
|
+
docs = [
|
|
60
|
+
"flexoki-zensical>=0.1.1",
|
|
61
|
+
"mkdocs-material>=9.7.7",
|
|
62
|
+
"mkdocstrings[python]>=1.0.4",
|
|
63
|
+
"pymdown-extensions>=11.0.1",
|
|
64
|
+
"zensical>=0.0.43",
|
|
65
|
+
]
|
|
66
|
+
|
|
67
|
+
[tool.uv.dependency-groups]
|
|
68
|
+
dev = { requires-python = ">=3.11" }
|
|
69
|
+
|
|
70
|
+
[tool.pytest.ini_options]
|
|
71
|
+
testpaths = ["tests"]
|
|
72
|
+
pythonpath = ["src"]
|
|
73
|
+
addopts = [
|
|
74
|
+
"-ra",
|
|
75
|
+
]
|
|
76
|
+
|
|
77
|
+
[tool.ruff]
|
|
78
|
+
target-version = "py310"
|
|
79
|
+
line-length = 100
|
|
80
|
+
|
|
81
|
+
[tool.ruff.lint]
|
|
82
|
+
select = [
|
|
83
|
+
"E",
|
|
84
|
+
"F",
|
|
85
|
+
"I",
|
|
86
|
+
"B",
|
|
87
|
+
"UP",
|
|
88
|
+
]
|
|
89
|
+
|
|
90
|
+
[tool.ruff.format]
|
|
91
|
+
quote-style = "double"
|
|
92
|
+
indent-style = "space"
|
|
93
|
+
|
|
94
|
+
[tool.pyright]
|
|
95
|
+
pythonVersion = "3.10"
|
|
96
|
+
include = ["src"]
|
|
97
|
+
typeCheckingMode = "standard"
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"""Application-facing API for terminal HMM animations."""
|
|
2
|
+
|
|
3
|
+
from .exceptions import (
|
|
4
|
+
AnihmmError,
|
|
5
|
+
AnimationConfigError,
|
|
6
|
+
AnimationTimeoutError,
|
|
7
|
+
FrameCompilationError,
|
|
8
|
+
InvalidTransitionError,
|
|
9
|
+
SequenceError,
|
|
10
|
+
SessionError,
|
|
11
|
+
)
|
|
12
|
+
from .models import HMMFrame
|
|
13
|
+
from .playback import (
|
|
14
|
+
AnimationSession,
|
|
15
|
+
AsyncAnimationSession,
|
|
16
|
+
PlaybackOptions,
|
|
17
|
+
ProcessingOptions,
|
|
18
|
+
ProgressSession,
|
|
19
|
+
animate_frames,
|
|
20
|
+
async_loading_animation,
|
|
21
|
+
async_processing_animation,
|
|
22
|
+
loading_animation,
|
|
23
|
+
print_frame_in_place,
|
|
24
|
+
processing_animation,
|
|
25
|
+
progress_animation,
|
|
26
|
+
)
|
|
27
|
+
from .sequence import HMMSequence, compile_steps
|
|
28
|
+
|
|
29
|
+
__all__ = [
|
|
30
|
+
"AnimationSession",
|
|
31
|
+
"AnimationConfigError",
|
|
32
|
+
"AnimationTimeoutError",
|
|
33
|
+
"AnihmmError",
|
|
34
|
+
"AsyncAnimationSession",
|
|
35
|
+
"FrameCompilationError",
|
|
36
|
+
"HMMFrame",
|
|
37
|
+
"HMMSequence",
|
|
38
|
+
"InvalidTransitionError",
|
|
39
|
+
"PlaybackOptions",
|
|
40
|
+
"ProcessingOptions",
|
|
41
|
+
"ProgressSession",
|
|
42
|
+
"SequenceError",
|
|
43
|
+
"SessionError",
|
|
44
|
+
"async_loading_animation",
|
|
45
|
+
"async_processing_animation",
|
|
46
|
+
"animate_frames",
|
|
47
|
+
"compile_steps",
|
|
48
|
+
"loading_animation",
|
|
49
|
+
"print_frame_in_place",
|
|
50
|
+
"progress_animation",
|
|
51
|
+
"processing_animation",
|
|
52
|
+
]
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
NodeParts = tuple[str, int | None]
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def parse_node_id(node_id: object) -> NodeParts | None:
|
|
7
|
+
"""Parse a canonical ASCII HMM node identifier."""
|
|
8
|
+
if not isinstance(node_id, str):
|
|
9
|
+
return None
|
|
10
|
+
if node_id in {"S", "E"}:
|
|
11
|
+
return node_id, None
|
|
12
|
+
if len(node_id) < 2 or node_id[0] not in {"D", "I", "M"}:
|
|
13
|
+
return None
|
|
14
|
+
|
|
15
|
+
suffix = node_id[1:]
|
|
16
|
+
if not suffix.isascii() or not suffix.isdigit():
|
|
17
|
+
return None
|
|
18
|
+
if len(suffix) > 1 and suffix.startswith("0"):
|
|
19
|
+
return None
|
|
20
|
+
|
|
21
|
+
index = int(suffix)
|
|
22
|
+
if node_id[0] in {"D", "M"} and index < 1:
|
|
23
|
+
return None
|
|
24
|
+
return node_id[0], index
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from rich.cells import cell_len
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def normalize_terminal_symbol(value: object) -> str | None:
|
|
7
|
+
"""Return a stripped one-cell symbol, or ``None`` when invalid."""
|
|
8
|
+
if not isinstance(value, str):
|
|
9
|
+
return None
|
|
10
|
+
symbol = value.strip()
|
|
11
|
+
if len(symbol) != 1 or cell_len(symbol) != 1:
|
|
12
|
+
return None
|
|
13
|
+
return symbol
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import math
|
|
4
|
+
from threading import TIMEOUT_MAX
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def is_valid_columns(value: object) -> bool:
|
|
8
|
+
"""Return whether *value* is a positive, non-boolean integer."""
|
|
9
|
+
return type(value) is int and value >= 1
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def is_bool(value: object) -> bool:
|
|
13
|
+
"""Return whether *value* is exactly a boolean."""
|
|
14
|
+
return type(value) is bool
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def is_wait_duration(value: object) -> bool:
|
|
18
|
+
"""Return whether *value* is supported by platform threading waits."""
|
|
19
|
+
if type(value) is int:
|
|
20
|
+
return 0 <= value <= TIMEOUT_MAX
|
|
21
|
+
if type(value) is float:
|
|
22
|
+
return math.isfinite(value) and 0 <= value <= TIMEOUT_MAX
|
|
23
|
+
return False
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def is_playback_fps(value: object) -> bool:
|
|
27
|
+
"""Return whether *value* gives a platform-supported frame interval."""
|
|
28
|
+
if type(value) is int:
|
|
29
|
+
return value > 0
|
|
30
|
+
if type(value) is float:
|
|
31
|
+
return math.isfinite(value) and value >= 1 / TIMEOUT_MAX
|
|
32
|
+
return False
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"""Public exception hierarchy for anihmm."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class AnihmmError(Exception):
|
|
7
|
+
"""Base exception for public anihmm API failures."""
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class AnimationConfigError(AnihmmError, ValueError):
|
|
11
|
+
"""Invalid playback or rendering configuration."""
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class SequenceError(AnihmmError, ValueError):
|
|
15
|
+
"""Invalid semantic sequence construction."""
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class InvalidTransitionError(SequenceError):
|
|
19
|
+
"""Invalid lattice transition or node reference."""
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class FrameCompilationError(AnihmmError, ValueError):
|
|
23
|
+
"""Failure while compiling semantic steps into renderable frames."""
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class SessionError(AnihmmError, RuntimeError):
|
|
27
|
+
"""Failure while starting, stopping, or monitoring a background session."""
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class AnimationTimeoutError(SessionError, TimeoutError):
|
|
31
|
+
"""Animation session did not finish before the requested timeout."""
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
__all__ = [
|
|
35
|
+
"AnihmmError",
|
|
36
|
+
"AnimationConfigError",
|
|
37
|
+
"AnimationTimeoutError",
|
|
38
|
+
"FrameCompilationError",
|
|
39
|
+
"InvalidTransitionError",
|
|
40
|
+
"SequenceError",
|
|
41
|
+
"SessionError",
|
|
42
|
+
]
|