PyDTMC 11.0.0__tar.gz → 11.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.
Files changed (129) hide show
  1. pydtmc-11.1.0/LICENSE.md +18 -0
  2. pydtmc-11.1.0/LICENSES/MIT.txt +18 -0
  3. {pydtmc-11.0.0 → pydtmc-11.1.0}/MANIFEST.in +4 -3
  4. {pydtmc-11.0.0 → pydtmc-11.1.0}/PKG-INFO +3 -4
  5. {pydtmc-11.0.0 → pydtmc-11.1.0}/PyDTMC.egg-info/PKG-INFO +3 -4
  6. {pydtmc-11.0.0 → pydtmc-11.1.0}/PyDTMC.egg-info/SOURCES.txt +4 -0
  7. {pydtmc-11.0.0 → pydtmc-11.1.0}/README.md +2 -3
  8. pydtmc-11.1.0/REUSE.toml +7 -0
  9. {pydtmc-11.0.0 → pydtmc-11.1.0}/docs/source/api_reference/hidden_markov_model_methods_instance.rst +1 -0
  10. {pydtmc-11.0.0 → pydtmc-11.1.0}/docs/source/api_reference/markov_chain_methods_instance.rst +1 -0
  11. {pydtmc-11.0.0 → pydtmc-11.1.0}/docs/source/api_reference/markov_chain_properties.rst +2 -0
  12. {pydtmc-11.0.0 → pydtmc-11.1.0}/docs/source/conf.py +26 -27
  13. {pydtmc-11.0.0 → pydtmc-11.1.0}/pydtmc/__init__.py +4 -1
  14. {pydtmc-11.0.0 → pydtmc-11.1.0}/pydtmc/_analysis.py +41 -29
  15. {pydtmc-11.0.0 → pydtmc-11.1.0}/pydtmc/_base_classes.py +2 -0
  16. {pydtmc-11.0.0 → pydtmc-11.1.0}/pydtmc/_custom_types.py +30 -36
  17. {pydtmc-11.0.0 → pydtmc-11.1.0}/pydtmc/_dynamics.py +2 -0
  18. {pydtmc-11.0.0 → pydtmc-11.1.0}/pydtmc/_files_io.py +32 -11
  19. {pydtmc-11.0.0 → pydtmc-11.1.0}/pydtmc/_fitting.py +31 -33
  20. {pydtmc-11.0.0 → pydtmc-11.1.0}/pydtmc/_generators.py +167 -153
  21. pydtmc-11.1.0/pydtmc/_model_types.py +61 -0
  22. {pydtmc-11.0.0 → pydtmc-11.1.0}/pydtmc/_numerical.py +10 -9
  23. {pydtmc-11.0.0 → pydtmc-11.1.0}/pydtmc/_rendering.py +28 -43
  24. {pydtmc-11.0.0 → pydtmc-11.1.0}/pydtmc/_utilities.py +4 -3
  25. {pydtmc-11.0.0 → pydtmc-11.1.0}/pydtmc/_validation.py +19 -8
  26. {pydtmc-11.0.0 → pydtmc-11.1.0}/pydtmc/assessments.py +12 -11
  27. {pydtmc-11.0.0 → pydtmc-11.1.0}/pydtmc/comparisons.py +7 -5
  28. {pydtmc-11.0.0 → pydtmc-11.1.0}/pydtmc/hidden_markov_model.py +40 -1
  29. {pydtmc-11.0.0 → pydtmc-11.1.0}/pydtmc/markov_chain.py +89 -34
  30. {pydtmc-11.0.0 → pydtmc-11.1.0}/pydtmc/plotting.py +4 -2
  31. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/fixtures/fixtures_hmm_generators_instance.json +243 -3
  32. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/fixtures/fixtures_mc_fitting.json +201 -1
  33. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/fixtures/fixtures_mc_generators_instance.json +246 -44
  34. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/fixtures/fixtures_mc_generators_static.json +141 -21
  35. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/fixtures/fixtures_mc_measures.json +12 -12
  36. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/fixtures/fixtures_validation.json +82 -0
  37. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/test_conversions.py +116 -27
  38. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/test_decorators.py +1 -0
  39. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/test_hmm_generators_instance.py +31 -0
  40. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/test_mc_generators_instance.py +23 -0
  41. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/test_mc_measures.py +2 -6
  42. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/test_mc_properties.py +110 -0
  43. pydtmc-11.1.0/tests/test_typing.py +78 -0
  44. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/test_validation.py +17 -0
  45. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/utilities.py +13 -19
  46. pydtmc-11.0.0/LICENSE.md +0 -21
  47. {pydtmc-11.0.0 → pydtmc-11.1.0}/PyDTMC.egg-info/dependency_links.txt +0 -0
  48. {pydtmc-11.0.0 → pydtmc-11.1.0}/PyDTMC.egg-info/requires.txt +0 -0
  49. {pydtmc-11.0.0 → pydtmc-11.1.0}/PyDTMC.egg-info/top_level.txt +0 -0
  50. {pydtmc-11.0.0 → pydtmc-11.1.0}/data/empty +0 -0
  51. {pydtmc-11.0.0 → pydtmc-11.1.0}/docs/Makefile +0 -0
  52. {pydtmc-11.0.0 → pydtmc-11.1.0}/docs/build/empty +0 -0
  53. {pydtmc-11.0.0 → pydtmc-11.1.0}/docs/make.bat +0 -0
  54. {pydtmc-11.0.0 → pydtmc-11.1.0}/docs/source/_static/css/style.css +0 -0
  55. {pydtmc-11.0.0 → pydtmc-11.1.0}/docs/source/_templates/empty +0 -0
  56. {pydtmc-11.0.0 → pydtmc-11.1.0}/docs/source/advanced_topics/absorbing_markov_chains.rst +0 -0
  57. {pydtmc-11.0.0 → pydtmc-11.1.0}/docs/source/advanced_topics/assessments.rst +0 -0
  58. {pydtmc-11.0.0 → pydtmc-11.1.0}/docs/source/advanced_topics/chain_comparison.rst +0 -0
  59. {pydtmc-11.0.0 → pydtmc-11.1.0}/docs/source/advanced_topics/hidden_markov_models.rst +0 -0
  60. {pydtmc-11.0.0 → pydtmc-11.1.0}/docs/source/advanced_topics/hitting_passage.rst +0 -0
  61. {pydtmc-11.0.0 → pydtmc-11.1.0}/docs/source/advanced_topics/index.rst +0 -0
  62. {pydtmc-11.0.0 → pydtmc-11.1.0}/docs/source/advanced_topics/long_term_behavior.rst +0 -0
  63. {pydtmc-11.0.0 → pydtmc-11.1.0}/docs/source/advanced_topics/markov_chain_analysis.rst +0 -0
  64. {pydtmc-11.0.0 → pydtmc-11.1.0}/docs/source/advanced_topics/mixing_convergence.rst +0 -0
  65. {pydtmc-11.0.0 → pydtmc-11.1.0}/docs/source/advanced_topics/reduction_aggregation.rst +0 -0
  66. {pydtmc-11.0.0 → pydtmc-11.1.0}/docs/source/advanced_topics/simulation_empirical_analysis.rst +0 -0
  67. {pydtmc-11.0.0 → pydtmc-11.1.0}/docs/source/advanced_topics/transition_paths_analysis.rst +0 -0
  68. {pydtmc-11.0.0 → pydtmc-11.1.0}/docs/source/advanced_topics/visualization.rst +0 -0
  69. {pydtmc-11.0.0 → pydtmc-11.1.0}/docs/source/api_reference/custom_exceptions.rst +0 -0
  70. {pydtmc-11.0.0 → pydtmc-11.1.0}/docs/source/api_reference/hidden_markov_model.rst +0 -0
  71. {pydtmc-11.0.0 → pydtmc-11.1.0}/docs/source/api_reference/hidden_markov_model_methods_static.rst +0 -0
  72. {pydtmc-11.0.0 → pydtmc-11.1.0}/docs/source/api_reference/hidden_markov_model_properties.rst +0 -0
  73. {pydtmc-11.0.0 → pydtmc-11.1.0}/docs/source/api_reference/index.rst +0 -0
  74. {pydtmc-11.0.0 → pydtmc-11.1.0}/docs/source/api_reference/markov_chain.rst +0 -0
  75. {pydtmc-11.0.0 → pydtmc-11.1.0}/docs/source/api_reference/markov_chain_methods_static.rst +0 -0
  76. {pydtmc-11.0.0 → pydtmc-11.1.0}/docs/source/api_reference/other_assessment_functions.rst +0 -0
  77. {pydtmc-11.0.0 → pydtmc-11.1.0}/docs/source/api_reference/other_comparison_functions.rst +0 -0
  78. {pydtmc-11.0.0 → pydtmc-11.1.0}/docs/source/api_reference/other_plotting_functions.rst +0 -0
  79. {pydtmc-11.0.0 → pydtmc-11.1.0}/docs/source/genindex.rst +0 -0
  80. {pydtmc-11.0.0 → pydtmc-11.1.0}/docs/source/getting_started/first_hidden_markov_model.rst +0 -0
  81. {pydtmc-11.0.0 → pydtmc-11.1.0}/docs/source/getting_started/first_markov_chain.rst +0 -0
  82. {pydtmc-11.0.0 → pydtmc-11.1.0}/docs/source/getting_started/index.rst +0 -0
  83. {pydtmc-11.0.0 → pydtmc-11.1.0}/docs/source/getting_started/installation.rst +0 -0
  84. {pydtmc-11.0.0 → pydtmc-11.1.0}/docs/source/index.rst +0 -0
  85. {pydtmc-11.0.0 → pydtmc-11.1.0}/pydtmc/_constants.py +0 -0
  86. {pydtmc-11.0.0 → pydtmc-11.1.0}/pydtmc/_decorators.py +0 -0
  87. {pydtmc-11.0.0 → pydtmc-11.1.0}/pydtmc/exceptions.py +0 -0
  88. {pydtmc-11.0.0 → pydtmc-11.1.0}/pyproject.toml +0 -0
  89. {pydtmc-11.0.0 → pydtmc-11.1.0}/requirements.txt +0 -0
  90. {pydtmc-11.0.0 → pydtmc-11.1.0}/setup.cfg +0 -0
  91. {pydtmc-11.0.0 → pydtmc-11.1.0}/setup.py +0 -0
  92. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/__init__.py +0 -0
  93. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/benchmarks.py +0 -0
  94. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/conftest.py +0 -0
  95. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/files/file_empty.txt +0 -0
  96. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/files/file_filled.txt +0 -0
  97. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/files/file_noext +0 -0
  98. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/fixtures/fixtures_aliases.json +0 -0
  99. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/fixtures/fixtures_assessments.json +0 -0
  100. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/fixtures/fixtures_benchmarks.json +0 -0
  101. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/fixtures/fixtures_comparisons.json +0 -0
  102. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/fixtures/fixtures_conversions.json +0 -0
  103. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/fixtures/fixtures_hmm.json +0 -0
  104. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/fixtures/fixtures_hmm_classification.json +0 -0
  105. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/fixtures/fixtures_hmm_dynamics.json +0 -0
  106. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/fixtures/fixtures_hmm_fitting.json +0 -0
  107. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/fixtures/fixtures_hmm_generators_static.json +0 -0
  108. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/fixtures/fixtures_hmm_measures.json +0 -0
  109. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/fixtures/fixtures_hmm_properties.json +0 -0
  110. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/fixtures/fixtures_mc_classification.json +0 -0
  111. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/fixtures/fixtures_mc_dynamics.json +0 -0
  112. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/fixtures/fixtures_mc_properties.json +0 -0
  113. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/fixtures/fixtures_plotting.json +0 -0
  114. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/fixtures/fixtures_utilities.json +0 -0
  115. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/test_aliases.py +0 -0
  116. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/test_assessments.py +0 -0
  117. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/test_comparisons.py +0 -0
  118. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/test_hmm_classification.py +0 -0
  119. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/test_hmm_dynamics.py +0 -0
  120. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/test_hmm_fitting.py +0 -0
  121. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/test_hmm_generators_static.py +0 -0
  122. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/test_hmm_measures.py +0 -0
  123. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/test_hmm_properties.py +0 -0
  124. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/test_mc_classification.py +0 -0
  125. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/test_mc_dynamics.py +0 -0
  126. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/test_mc_fitting.py +0 -0
  127. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/test_mc_generators_static.py +0 -0
  128. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/test_plotting.py +0 -0
  129. {pydtmc-11.0.0 → pydtmc-11.1.0}/tests/test_utilities.py +0 -0
@@ -0,0 +1,18 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019-2026 Tommaso Belluzzo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
6
+ associated documentation files (the "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
9
+ following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all copies or substantial
12
+ portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
15
+ LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
16
+ EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
18
+ USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,18 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019-2026 Tommaso Belluzzo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
6
+ associated documentation files (the "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
9
+ following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all copies or substantial
12
+ portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
15
+ LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
16
+ EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
18
+ USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,8 +1,9 @@
1
1
  # Inclusions
2
+ graft LICENSES
2
3
  graft data
3
4
  graft docs
4
5
  graft tests
5
- include LICENSE.md README.md requirements.txt setup.cfg setup.py
6
+ include LICENSE.md README.md REUSE.toml pyproject.toml requirements.txt setup.cfg setup.py
6
7
 
7
8
  # Exclusions
8
9
  prune .git
@@ -12,8 +13,8 @@ prune dist
12
13
  prune docs/build
13
14
  prune examples
14
15
  prune images
15
- global-exclude .env .git* __pycache__ *.dll *.py[cdo] *.so *.yaml *~
16
- exclude CODE_OF_CONDUCT.md CONTRIBUTING.md
16
+ global-exclude .env .git* __pycache__ *.dll *.py[cdo] *.so *.yaml mmt-*.dat *~
17
+ exclude CODE_OF_CONDUCT.md CONTRIBUTING.md context7.json llms.txt
17
18
 
18
19
  # Empty Files
19
20
  global-include empty
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PyDTMC
3
- Version: 11.0.0
3
+ Version: 11.1.0
4
4
  Summary: Python library for analyzing, simulating, and visualizing discrete-time Markov chains and hidden Markov models.
5
5
  Home-page: https://github.com/TommasoBelluzzo/PyDTMC
6
6
  Author: Tommaso Belluzzo
@@ -109,7 +109,8 @@ PyDTMC is a lightweight Python library focused on discrete-time Markov chains an
109
109
 
110
110
  ## Installation
111
111
 
112
- PyDTMC requires **Python 3.12 or greater** and depends on [NumPy](https://numpy.org/), [SciPy](https://scipy.org/), [NetworkX](https://networkx.org/), and [Matplotlib](https://matplotlib.org/).
112
+ PyDTMC requires **Python 3.12 or greater** and depends on [NumPy](https://numpy.org/), [SciPy](https://scipy.org/), [NetworkX](https://networkx.org/), and [Matplotlib](https://matplotlib.org/).\
113
+ Extended rendering for plots is supported through the optional integration of [Graphviz](https://graphviz.org/) and [pydot](https://pypi.org/project/pydot/).
113
114
 
114
115
  For the [PyPI](https://pypi.org/) installation:
115
116
 
@@ -129,8 +130,6 @@ For the latest development version:
129
130
  pip install git+https://github.com/TommasoBelluzzo/PyDTMC.git
130
131
  ```
131
132
 
132
- **Note:** [Graphviz](https://graphviz.org/) and [pydot](https://pypi.org/project/pydot/) are recommended for graph visualization using the `plot_graph` function.
133
-
134
133
  ## Resources
135
134
 
136
135
  For additional functionality, mathematical definitions, and usage examples, refer to the [documentation](https://pydtmc.readthedocs.io/).
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PyDTMC
3
- Version: 11.0.0
3
+ Version: 11.1.0
4
4
  Summary: Python library for analyzing, simulating, and visualizing discrete-time Markov chains and hidden Markov models.
5
5
  Home-page: https://github.com/TommasoBelluzzo/PyDTMC
6
6
  Author: Tommaso Belluzzo
@@ -109,7 +109,8 @@ PyDTMC is a lightweight Python library focused on discrete-time Markov chains an
109
109
 
110
110
  ## Installation
111
111
 
112
- PyDTMC requires **Python 3.12 or greater** and depends on [NumPy](https://numpy.org/), [SciPy](https://scipy.org/), [NetworkX](https://networkx.org/), and [Matplotlib](https://matplotlib.org/).
112
+ PyDTMC requires **Python 3.12 or greater** and depends on [NumPy](https://numpy.org/), [SciPy](https://scipy.org/), [NetworkX](https://networkx.org/), and [Matplotlib](https://matplotlib.org/).\
113
+ Extended rendering for plots is supported through the optional integration of [Graphviz](https://graphviz.org/) and [pydot](https://pypi.org/project/pydot/).
113
114
 
114
115
  For the [PyPI](https://pypi.org/) installation:
115
116
 
@@ -129,8 +130,6 @@ For the latest development version:
129
130
  pip install git+https://github.com/TommasoBelluzzo/PyDTMC.git
130
131
  ```
131
132
 
132
- **Note:** [Graphviz](https://graphviz.org/) and [pydot](https://pypi.org/project/pydot/) are recommended for graph visualization using the `plot_graph` function.
133
-
134
133
  ## Resources
135
134
 
136
135
  For additional functionality, mathematical definitions, and usage examples, refer to the [documentation](https://pydtmc.readthedocs.io/).
@@ -1,10 +1,12 @@
1
1
  LICENSE.md
2
2
  MANIFEST.in
3
3
  README.md
4
+ REUSE.toml
4
5
  pyproject.toml
5
6
  requirements.txt
6
7
  setup.cfg
7
8
  setup.py
9
+ LICENSES/MIT.txt
8
10
  PyDTMC.egg-info/PKG-INFO
9
11
  PyDTMC.egg-info/SOURCES.txt
10
12
  PyDTMC.egg-info/dependency_links.txt
@@ -59,6 +61,7 @@ pydtmc/_dynamics.py
59
61
  pydtmc/_files_io.py
60
62
  pydtmc/_fitting.py
61
63
  pydtmc/_generators.py
64
+ pydtmc/_model_types.py
62
65
  pydtmc/_numerical.py
63
66
  pydtmc/_rendering.py
64
67
  pydtmc/_utilities.py
@@ -92,6 +95,7 @@ tests/test_mc_generators_static.py
92
95
  tests/test_mc_measures.py
93
96
  tests/test_mc_properties.py
94
97
  tests/test_plotting.py
98
+ tests/test_typing.py
95
99
  tests/test_utilities.py
96
100
  tests/test_validation.py
97
101
  tests/utilities.py
@@ -41,7 +41,8 @@ PyDTMC is a lightweight Python library focused on discrete-time Markov chains an
41
41
 
42
42
  ## Installation
43
43
 
44
- PyDTMC requires **Python 3.12 or greater** and depends on [NumPy](https://numpy.org/), [SciPy](https://scipy.org/), [NetworkX](https://networkx.org/), and [Matplotlib](https://matplotlib.org/).
44
+ PyDTMC requires **Python 3.12 or greater** and depends on [NumPy](https://numpy.org/), [SciPy](https://scipy.org/), [NetworkX](https://networkx.org/), and [Matplotlib](https://matplotlib.org/).\
45
+ Extended rendering for plots is supported through the optional integration of [Graphviz](https://graphviz.org/) and [pydot](https://pypi.org/project/pydot/).
45
46
 
46
47
  For the [PyPI](https://pypi.org/) installation:
47
48
 
@@ -61,8 +62,6 @@ For the latest development version:
61
62
  pip install git+https://github.com/TommasoBelluzzo/PyDTMC.git
62
63
  ```
63
64
 
64
- **Note:** [Graphviz](https://graphviz.org/) and [pydot](https://pypi.org/project/pydot/) are recommended for graph visualization using the `plot_graph` function.
65
-
66
65
  ## Resources
67
66
 
68
67
  For additional functionality, mathematical definitions, and usage examples, refer to the [documentation](https://pydtmc.readthedocs.io/).
@@ -0,0 +1,7 @@
1
+ version = 1
2
+
3
+ [[annotations]]
4
+ path = "**"
5
+ precedence = "closest"
6
+ SPDX-FileCopyrightText = "Tommaso Belluzzo"
7
+ SPDX-License-Identifier = "MIT"
@@ -26,6 +26,7 @@ Instance Methods
26
26
  restrict,
27
27
  sequence_probability,
28
28
  simulate,
29
+ sort,
29
30
  synchronization_entropy,
30
31
  synchronization_information,
31
32
  to_dictionary,
@@ -55,6 +55,7 @@ Instance Methods
55
55
  sensitivity,
56
56
  sequence_probability,
57
57
  simulate,
58
+ sort,
58
59
  spectral_aggregation,
59
60
  stationary_perturbation_bound,
60
61
  stationary_sampling,
@@ -19,6 +19,7 @@ Properties
19
19
  deviation_matrix,
20
20
  dobrushin_coefficient,
21
21
  doeblin_coefficient,
22
+ eigenvalue_moduli,
22
23
  entropy_production_rate,
23
24
  entropy_rate,
24
25
  entropy_rate_normalized,
@@ -57,6 +58,7 @@ Properties
57
58
  recurrent_states,
58
59
  relaxation_rate,
59
60
  size,
61
+ slem,
60
62
  states,
61
63
  stationary_current,
62
64
  stationary_flux,
@@ -91,7 +91,7 @@ extensions = [
91
91
  master_doc = 'index'
92
92
  source_suffix = '.rst'
93
93
  source_encoding = 'utf-8'
94
- exclude_patterns = ['_build']
94
+ exclude_patterns = ['_build', 'mmt-*.dat']
95
95
  templates_path = ['_templates']
96
96
  pygments_style = 'sphinx'
97
97
  nitpick_ignore = []
@@ -141,7 +141,6 @@ autodoc_typehints_format = 'short'
141
141
 
142
142
  # Autodoc Typehints
143
143
 
144
- set_type_checking_flag = True
145
144
  simplify_optional_unions = True
146
145
  always_use_bars_union = True
147
146
  typehints_fully_qualified = False
@@ -155,7 +154,7 @@ typehints_use_rtype = False
155
154
  # ePub
156
155
 
157
156
  epub_title = project
158
- epub_exclude_files = ['search.html']
157
+ epub_exclude_files = ['search.html', 'llms.txt']
159
158
 
160
159
  # HTML
161
160
 
@@ -166,6 +165,7 @@ html_short_title = ''
166
165
  html_show_sourcelink = False
167
166
  html_show_sphinx = False
168
167
  html_static_path = ['_static']
168
+ html_extra_path = ['../../llms.txt'] if _osp.isfile(_osp.join(_base_directory, '../../llms.txt')) else []
169
169
  html_style = 'css/style.css'
170
170
  html_theme = 'sphinx_rtd_theme'
171
171
  html_theme_options = {'language_selector': False, 'version_selector': False}
@@ -473,26 +473,6 @@ class _SphinxPostTransformReturnTypes(_sppt.SphinxPostTransform):
473
473
  # FUNCTIONS #
474
474
  #############
475
475
 
476
- # noinspection PyUnusedLocal
477
- def _hook_autodoc_before_process_signature(app, obj, bound_method): # pylint: disable=unused-argument
478
-
479
- from pydtmc import assessments
480
- from pydtmc import comparisons
481
- from pydtmc import plotting
482
-
483
- from pydtmc.hidden_markov_model import HiddenMarkovModel
484
- from pydtmc.markov_chain import MarkovChain
485
-
486
- assessments.__dict__.setdefault('HiddenMarkovModel', HiddenMarkovModel)
487
- assessments.__dict__.setdefault('MarkovChain', MarkovChain)
488
-
489
- comparisons.__dict__.setdefault('HiddenMarkovModel', HiddenMarkovModel)
490
- comparisons.__dict__.setdefault('MarkovChain', MarkovChain)
491
-
492
- plotting.__dict__.setdefault('HiddenMarkovModel', HiddenMarkovModel)
493
- plotting.__dict__.setdefault('MarkovChain', MarkovChain)
494
-
495
-
496
476
  # noinspection PyUnusedLocal
497
477
  def _hook_autodoc_process_docstring(app, what, name, obj, options, lines): # pylint: disable=unused-argument
498
478
 
@@ -520,6 +500,25 @@ def _hook_autodoc_process_docstring(app, what, name, obj, options, lines): # py
520
500
  lines.append(f':rtype: {annotation}')
521
501
 
522
502
 
503
+ # noinspection PyUnusedLocal
504
+ def _hook_doctree_read(app, doctree): # pylint: disable=unused-argument
505
+
506
+ aliases = {
507
+ 'pydtmc.hidden_markov_model.HiddenMarkovModel': 'pydtmc.HiddenMarkovModel',
508
+ 'pydtmc.markov_chain.MarkovChain': 'pydtmc.MarkovChain'
509
+ }
510
+
511
+ for node in doctree.findall(_san.pending_xref):
512
+
513
+ if node.get('refdomain') != 'py':
514
+ continue
515
+
516
+ target = node.get('reftarget')
517
+
518
+ if target in aliases:
519
+ node['reftarget'] = aliases[target]
520
+
521
+
523
522
  # noinspection PyUnusedLocal
524
523
  def _hook_html_page_context(app, pagename, templatename, context, doctree): # pylint: disable=unused-argument
525
524
 
@@ -604,8 +603,8 @@ def setup(app):
604
603
  app.add_post_transform(_SphinxPostTransformLists)
605
604
  app.add_post_transform(_SphinxPostTransformProperties)
606
605
 
607
- app.connect('autodoc-before-process-signature', _hook_autodoc_before_process_signature)
608
606
  app.connect('autodoc-process-docstring', _hook_autodoc_process_docstring, priority=700)
609
- app.connect('builder-inited', _hook_builder_inited)
610
- app.connect('html-page-context', _hook_html_page_context)
611
- app.connect('missing-reference', _hook_missing_reference)
607
+ app.connect('builder-inited', _hook_builder_inited, priority=500)
608
+ app.connect('doctree-read', _hook_doctree_read, priority=500)
609
+ app.connect('html-page-context', _hook_html_page_context, priority=500)
610
+ app.connect('missing-reference', _hook_missing_reference, priority=500)
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  __title__ = 'PyDTMC'
4
- __version__ = '11.0.0'
4
+ __version__ = '11.1.0'
5
5
  __author__ = 'Tommaso Belluzzo'
6
6
 
7
7
  __all__ = [
@@ -88,3 +88,6 @@ from pydtmc.plotting import (
88
88
  plot_spectrum,
89
89
  plot_trellis
90
90
  )
91
+
92
+ from pydtmc import _custom_types as _ct
93
+ _ct.initialize_library_types()
@@ -1,5 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
+ from __future__ import annotations
4
+
3
5
  __all__ = [
4
6
  'hmm_block_entropy',
5
7
  'hmm_conditional_probabilities',
@@ -1791,12 +1793,9 @@ def mc_time_correlations(mc: _ct.tmc, states1: _ct.tseq, states2: _ct.oseq, time
1791
1793
  return tcs
1792
1794
 
1793
1795
 
1794
- def mc_time_relaxations(mc: _ct.tmc, states: _ct.tseq, initial_distribution: _ct.tarray, time_points: _ct.ttimes_in) -> _ct.otimes_out:
1795
-
1796
- p, size, pi = mc.p, mc.size, mc.pi
1796
+ def mc_time_relaxations(mc: _ct.tmc, states: _ct.tseq, initial_distribution: _ct.tarray, time_points: _ct.ttimes_in) -> _ct.ttimes_out:
1797
1797
 
1798
- if len(pi) > 1:
1799
- return None
1798
+ p, size = mc.p, mc.size
1800
1799
 
1801
1800
  observations = _np.zeros(size, dtype=float)
1802
1801
 
@@ -2129,10 +2128,8 @@ def mc_implied_timescales(mc: _ct.tmc) -> _ct.oarray:
2129
2128
  if not mc.is_irreducible:
2130
2129
  return None
2131
2130
 
2132
- ev = _n.eigenvalues_sorted(mc.p)[::-1]
2133
-
2134
- remaining = ev[1:]
2135
- timescales = _np.zeros(remaining.shape, dtype=float)
2131
+ evalues = mc.eigenvalue_moduli[::-1]
2132
+ remaining = evalues[1:]
2136
2133
 
2137
2134
  infinite_mask = remaining >= 1.0
2138
2135
  infinite_mask[:mc.period - 1] = True
@@ -2140,6 +2137,7 @@ def mc_implied_timescales(mc: _ct.tmc) -> _ct.oarray:
2140
2137
  zero_mask = (remaining <= _c.FTOL) & ~infinite_mask
2141
2138
  finite_mask = ~(infinite_mask | zero_mask)
2142
2139
 
2140
+ timescales = _np.zeros(remaining.shape, dtype=float)
2143
2141
  timescales[infinite_mask] = _np.inf
2144
2142
  timescales[zero_mask] = 0.0
2145
2143
  timescales[finite_mask] = -1.0 / _np.log(remaining[finite_mask])
@@ -2168,22 +2166,47 @@ def mc_is_aperiodic(mc: _ct.tmc) -> bool:
2168
2166
  def mc_is_reversible(mc: _ct.tmc, recurrent_classes_indices: _ct.tlists_int) -> bool:
2169
2167
 
2170
2168
  p = mc.p
2169
+ tolerance = _np.log1p(_c.ETOL)
2171
2170
 
2172
2171
  for indices in recurrent_classes_indices:
2173
2172
 
2174
2173
  pr = p[_np.ix_(indices, indices)]
2174
+ size = pr.shape[0]
2175
2175
 
2176
2176
  support = pr > 0.0
2177
2177
 
2178
2178
  if not _np.array_equal(support, _np.transpose(support)):
2179
2179
  return False
2180
2180
 
2181
- pi = _n.gth_solve(pr)
2181
+ with _np.errstate(divide='ignore'):
2182
+ log_pr = _np.log(pr)
2182
2183
 
2183
- flow = pi[:, _np.newaxis] * pr
2184
+ weights = _np.full(size, _np.nan, dtype=float)
2185
+ weights[0] = 0.0
2184
2186
 
2185
- if _np.max(_np.abs(flow - _np.transpose(flow))) > _c.FTOL:
2186
- return False
2187
+ worklist = [0]
2188
+ position = 0
2189
+
2190
+ while position < len(worklist):
2191
+
2192
+ i = worklist[position]
2193
+ position += 1
2194
+
2195
+ for j in _np.flatnonzero(support[i, :]):
2196
+
2197
+ if i == j:
2198
+ continue
2199
+
2200
+ weight = weights[i] + (log_pr[i, j] - log_pr[j, i])
2201
+
2202
+ if _np.isnan(weights[j]):
2203
+
2204
+ weights[j] = weight
2205
+ worklist.append(j)
2206
+
2207
+ elif abs(weights[j] - weight) > tolerance:
2208
+
2209
+ return False
2187
2210
 
2188
2211
  return True
2189
2212
 
@@ -2330,24 +2353,13 @@ def mc_quasi_stationary_distribution(mc: _ct.tmc) -> _ct.oarray: # pylint: disa
2330
2353
 
2331
2354
  def mc_sensitivity(mc: _ct.tmc, state: int) -> _ct.oarray:
2332
2355
 
2333
- if not mc.is_irreducible:
2334
- return None
2335
-
2336
- p, size, pi = mc.p, mc.size, mc.pi[0]
2337
-
2338
- lev = _np.ones(size, dtype=float)
2339
- rev = pi
2340
-
2341
- a = _np.transpose(p) - _np.eye(size)
2342
- a = _np.transpose(_np.concatenate((a, [lev])))
2343
-
2344
- b = _np.zeros(size, dtype=float)
2345
- b[state] = 1.0
2356
+ fm = mc.fundamental_matrix
2346
2357
 
2347
- phi = _npl.lstsq(a, b, rcond=-1)
2348
- phi = _np.delete(phi[0], -1)
2358
+ if fm is None:
2359
+ return None
2349
2360
 
2350
- s = -_np.outer(rev, phi) + (_np.dot(phi, rev) * _np.outer(rev, lev))
2361
+ pi = mc.pi[0]
2362
+ s = _np.outer(pi, fm[:, state] - pi[state])
2351
2363
 
2352
2364
  return s
2353
2365
 
@@ -1,5 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
+ from __future__ import annotations
4
+
3
5
  __all__ = [
4
6
  'Model'
5
7
  ]
@@ -67,6 +67,7 @@ __all__ = [
67
67
  'tlim_num', 'olim_num',
68
68
  'trfunc', 'orfunc',
69
69
  'trfunc_f', 'orfunc_f',
70
+ 'tsfunc', 'osfunc',
70
71
  # Compound Types - Specific
71
72
  'tass_cp', 'oass_cp',
72
73
  'tass_cnt', 'oass_cnt',
@@ -132,10 +133,8 @@ import scipy.sparse as _spsp
132
133
 
133
134
  try:
134
135
  import pandas as _pd
135
- _pandas_found = True
136
136
  except ImportError:
137
137
  _pd = None
138
- _pandas_found = False
139
138
 
140
139
 
141
140
  #########
@@ -183,7 +182,7 @@ oarray = _tp.Optional[tarray]
183
182
  tnum = _tp.Union[float, int]
184
183
  onum = _tp.Optional[tnum]
185
184
 
186
- if _pandas_found:
185
+ if _pd is not None:
187
186
  tvec = _tp.Union[_tp.List[tnum], tarray, _pd.Series]
188
187
  tmat = _tp.Union[_tp.List[_tp.List[tnum]], tarray, _spsp.spmatrix, _pd.DataFrame]
189
188
  else:
@@ -197,39 +196,17 @@ omat = _tp.Optional[tmat]
197
196
 
198
197
  if _tp.TYPE_CHECKING:
199
198
 
200
- from .hidden_markov_model import HiddenMarkovModel
201
- from .markov_chain import MarkovChain
202
-
203
- thmm: _tp.TypeAlias = HiddenMarkovModel
204
- tmc: _tp.TypeAlias = MarkovChain
205
-
206
- else:
207
- thmm = _tp.ForwardRef('HiddenMarkovModel')
208
- tmc = _tp.ForwardRef('MarkovChain')
209
-
210
- ohmm = _tp.Optional[thmm]
211
- omc = _tp.Optional[tmc]
212
-
213
- tmdl = _tp.Union[thmm, tmc]
214
- omdl = _tp.Optional[tmdl]
215
-
216
- tlist_hmm = _tp.List[thmm]
217
- olist_hmm = _tp.Optional[tlist_hmm]
218
-
219
- tlist_mc = _tp.List[tmc]
220
- olist_mc = _tp.Optional[tlist_mc]
221
-
222
- tlist_mdl = _tp.List[tmdl]
223
- olist_mdl = _tp.Optional[tlist_mdl]
224
-
225
- thmms = _tp.Union[thmm, tlist_hmm]
226
- ohmms = _tp.Optional[thmms]
227
-
228
- tmcs = _tp.Union[tmc, tlist_mc]
229
- omcs = _tp.Optional[tmcs]
230
-
231
- tmdls = _tp.Union[tmdl, tlist_mdl]
232
- omdls = _tp.Optional[tmdls]
199
+ from ._model_types import (
200
+ thmm, ohmm,
201
+ thmms, ohmms,
202
+ tmc, omc,
203
+ tmcs, omcs,
204
+ tmdl, omdl,
205
+ tmdls, omdls,
206
+ tlist_hmm, olist_hmm,
207
+ tlist_mc, olist_mc,
208
+ tlist_mdl, olist_mdl
209
+ )
233
210
 
234
211
  # LISTS
235
212
 
@@ -340,6 +317,9 @@ orfunc = _tp.Optional[trfunc]
340
317
  trfunc_f = _tp.Union[trfunc, str]
341
318
  orfunc_f = _tp.Optional[trfunc_f]
342
319
 
320
+ tsfunc = _tp.Callable[[str], tany]
321
+ osfunc = _tp.Optional[tsfunc]
322
+
343
323
  # COMPOUND TYPES - SPECIFIC
344
324
 
345
325
  tass_cp = _tp.Tuple[oint, float, float]
@@ -464,3 +444,17 @@ trpaths = _tp.Union[_rpaths[ttup_int], _rpaths[ttup_str]]
464
444
  orpaths = _tp.Optional[trpaths]
465
445
  trpaths_str = _rpaths[ttup_str]
466
446
  orpaths_str = _tp.Optional[trpaths_str]
447
+
448
+
449
+ #############
450
+ # FUNCTIONS #
451
+ #############
452
+
453
+ def initialize_library_types():
454
+
455
+ from . import _model_types
456
+
457
+ globals().update({
458
+ name: getattr(_model_types, name)
459
+ for name in _model_types.__all__
460
+ })
@@ -1,5 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
+ from __future__ import annotations
4
+
3
5
  __all__ = [
4
6
  'hmm_predict',
5
7
  'hmm_predict_trajectory',