math-spec-mapping 0.4.2__py3-none-any.whl → 0.4.3__py3-none-any.whl
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.
- math_spec_mapping/Reports/__init__.py +2 -1
- math_spec_mapping/Reports/advanced.py +57 -0
- math_spec_mapping/Reports/general.py +20 -2
- math_spec_mapping/__init__.py +2 -0
- {math_spec_mapping-0.4.2.dist-info → math_spec_mapping-0.4.3.dist-info}/METADATA +2 -1
- {math_spec_mapping-0.4.2.dist-info → math_spec_mapping-0.4.3.dist-info}/RECORD +9 -8
- {math_spec_mapping-0.4.2.dist-info → math_spec_mapping-0.4.3.dist-info}/LICENSE +0 -0
- {math_spec_mapping-0.4.2.dist-info → math_spec_mapping-0.4.3.dist-info}/WHEEL +0 -0
- {math_spec_mapping-0.4.2.dist-info → math_spec_mapping-0.4.3.dist-info}/top_level.txt +0 -0
@@ -2,7 +2,7 @@ from .node_map import create_action_chains_graph
|
|
2
2
|
from .boundary_actions import write_out_boundary_actions
|
3
3
|
from .policies import write_out_policies
|
4
4
|
from .mechanisms import write_out_mechanisms
|
5
|
-
from .general import load_svg_graphviz
|
5
|
+
from .general import load_svg_graphviz, convert_markdown_to_pdf
|
6
6
|
from .html import (
|
7
7
|
write_basic_report_full,
|
8
8
|
write_action_chain_reports,
|
@@ -32,3 +32,4 @@ from .state import (
|
|
32
32
|
write_initial_state_variables_tables,
|
33
33
|
)
|
34
34
|
from .parameters import write_parameter_table_markdown
|
35
|
+
from .advanced import write_glossary_report
|
@@ -0,0 +1,57 @@
|
|
1
|
+
from ..Classes import MathSpec
|
2
|
+
from .state import write_state_section
|
3
|
+
|
4
|
+
|
5
|
+
def write_glossary_report(ms: MathSpec, directory: str) -> None:
|
6
|
+
"""Function to write a report of each component and its description in MSML
|
7
|
+
|
8
|
+
Args:
|
9
|
+
ms (MathSpec): The mathematical specification object
|
10
|
+
directory (str): Directory to put reports into
|
11
|
+
"""
|
12
|
+
out = "# Glossary\n\n"
|
13
|
+
|
14
|
+
out += "## Entities\n\n"
|
15
|
+
for entity in ms.entities:
|
16
|
+
if entity == "Global":
|
17
|
+
continue
|
18
|
+
entity = ms.entities[entity]
|
19
|
+
out += "**{}**: {}".format(entity.name, entity.notes)
|
20
|
+
out += "\n\n"
|
21
|
+
out += "\n"
|
22
|
+
|
23
|
+
out += "## State\n\n"
|
24
|
+
states = list(ms.state.keys())
|
25
|
+
states.remove("Global State")
|
26
|
+
states = ["Global State"] + states
|
27
|
+
for state in states:
|
28
|
+
out += "### {}\n\n".format(state)
|
29
|
+
out += write_state_section(ms.state[state])
|
30
|
+
out += "\n\n"
|
31
|
+
out += "\n\n"
|
32
|
+
|
33
|
+
for name, component in [
|
34
|
+
["Types", ms.types],
|
35
|
+
["Spaces", ms.spaces],
|
36
|
+
["Boundary Actions", ms.boundary_actions],
|
37
|
+
["Control Actions", ms.control_actions],
|
38
|
+
["Policies", ms.policies],
|
39
|
+
["Mechanisms", ms.mechanisms],
|
40
|
+
["Wiring", ms.wiring],
|
41
|
+
["Parameters", ms.parameters.parameter_map],
|
42
|
+
["Stateful Metrics", ms.stateful_metrics],
|
43
|
+
["Metrics", ms.metrics],
|
44
|
+
]:
|
45
|
+
out += "## {}\n\n".format(name)
|
46
|
+
for key in component:
|
47
|
+
if hasattr(component[key], "description"):
|
48
|
+
desc = component[key].description
|
49
|
+
else:
|
50
|
+
desc = component[key].notes
|
51
|
+
|
52
|
+
out += "**{}**: {}\n\n".format(key, desc)
|
53
|
+
out += "\n\n"
|
54
|
+
|
55
|
+
path = directory + "/Glossary.md"
|
56
|
+
with open(path, "w") as f:
|
57
|
+
f.write(out)
|
@@ -1,5 +1,6 @@
|
|
1
1
|
from graphviz import Digraph
|
2
2
|
import os
|
3
|
+
import pypandoc
|
3
4
|
|
4
5
|
|
5
6
|
def load_svg_graphviz(graph: Digraph, overwrite: bool = False) -> str:
|
@@ -23,7 +24,7 @@ def load_svg_graphviz(graph: Digraph, overwrite: bool = False) -> str:
|
|
23
24
|
assert "{}.gv".format(graph.name) not in os.listdir(".")
|
24
25
|
|
25
26
|
# Render the graph
|
26
|
-
graph.render(directory=".", format=
|
27
|
+
graph.render(directory=".", format="svg")
|
27
28
|
|
28
29
|
# Read the svg
|
29
30
|
with open("./{}.gv.svg".format(graph.name), "r") as f:
|
@@ -35,6 +36,7 @@ def load_svg_graphviz(graph: Digraph, overwrite: bool = False) -> str:
|
|
35
36
|
|
36
37
|
return svg
|
37
38
|
|
39
|
+
|
38
40
|
def write_header() -> str:
|
39
41
|
out = '<p>For explanations of generalized dynamical systems as well as how the mathematical specification library works in detail, please consult the documentation <a href="https://github.com/BlockScience/MSML/tree/main/docs">here</a></p>'
|
40
42
|
out += "Graph Legend:<br/>"
|
@@ -43,4 +45,20 @@ def write_header() -> str:
|
|
43
45
|
out += "Red Square: Policy<br/>"
|
44
46
|
out += "Blue Circle: Mechanism<br/>"
|
45
47
|
out += "Transparent Circle: State Variable"
|
46
|
-
return out
|
48
|
+
return out
|
49
|
+
|
50
|
+
|
51
|
+
def convert_markdown_to_pdf(md_path, pdf_path, pdflatex_path=None):
|
52
|
+
if pdflatex_path:
|
53
|
+
pypandoc.convert_file(
|
54
|
+
md_path,
|
55
|
+
"pdf",
|
56
|
+
outputfile=pdf_path,
|
57
|
+
extra_args=["--pdf-engine={}".format(pdflatex_path)],
|
58
|
+
)
|
59
|
+
else:
|
60
|
+
pypandoc.convert_file(
|
61
|
+
md_path,
|
62
|
+
"pdf",
|
63
|
+
outputfile=pdf_path,
|
64
|
+
)
|
math_spec_mapping/__init__.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: math-spec-mapping
|
3
|
-
Version: 0.4.
|
3
|
+
Version: 0.4.3
|
4
4
|
Summary: A library for easy mapping of mathematical specifications.
|
5
5
|
Author-email: Sean McOwen <Sean@Block.Science>
|
6
6
|
Classifier: Programming Language :: Python :: 3
|
@@ -15,6 +15,7 @@ Requires-Dist: pandas>=1.4
|
|
15
15
|
Requires-Dist: jsonschema>=4.21.1
|
16
16
|
Requires-Dist: PyGithub==2.5.0
|
17
17
|
Requires-Dist: python-dotenv>=1.0.0
|
18
|
+
Requires-Dist: pypandoc>=1.15
|
18
19
|
|
19
20
|
# Mathematical Specification Mapping Library (MSML)
|
20
21
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
math_spec_mapping/__init__.py,sha256
|
1
|
+
math_spec_mapping/__init__.py,sha256=8MbUccubjXcwkTrwi3AD8uFhokRYPwLXURNTLCnSbRM,1338
|
2
2
|
math_spec_mapping/schema.py,sha256=6mrRqzEnTTSXjb19xJ63MBp0KjKH0s7i6TfT4MkAY9k,233
|
3
3
|
math_spec_mapping/schema.schema.json,sha256=NyzUy899YR_5Y956ID5HQtgnRBrNTAN6QjrqCyBasRA,31005
|
4
4
|
math_spec_mapping/Classes/ActionTransmissionChannel.py,sha256=zWMo5QsgPh5WGIWXl-xOrZNMXYJXmK6Vejw1dQvi0og,246
|
@@ -42,10 +42,11 @@ math_spec_mapping/Load/stateful_metrics.py,sha256=eNXIsNmezVN75L3zMXUl8_JORShm_o
|
|
42
42
|
math_spec_mapping/Load/states.py,sha256=3YurI7eTNkN6nrXRFVrc58wH0VfM22XOuWE07HVpR7Y,1365
|
43
43
|
math_spec_mapping/Load/type.py,sha256=pIo3lYAP6sxukvbFTDvaun1lslgShksZy2froNnwAfA,4973
|
44
44
|
math_spec_mapping/Load/wiring.py,sha256=l1FhHNFRMKorn1oiRhsuMDsExcXnUmTjqQt5ElE-Bbk,3258
|
45
|
-
math_spec_mapping/Reports/__init__.py,sha256=
|
45
|
+
math_spec_mapping/Reports/__init__.py,sha256=OqmAKio9if1OknLoiTWTpaVq3PzfUCZdIEmZj3wS0z8,1190
|
46
|
+
math_spec_mapping/Reports/advanced.py,sha256=Y75ZYPBpr_HOJ64BrsjA5Rc0vmqiiTcEQWx8orOT74Q,1767
|
46
47
|
math_spec_mapping/Reports/boundary_actions.py,sha256=45BPp4QjWdD-3E9ZWwqgj_nI2-YdcI2ZZ19_Qv_K7Qk,1410
|
47
48
|
math_spec_mapping/Reports/control_actions.py,sha256=NksekZKIPFSIkubttFstKFthc5AU9B9PWRLSl9j1wWs,1216
|
48
|
-
math_spec_mapping/Reports/general.py,sha256=
|
49
|
+
math_spec_mapping/Reports/general.py,sha256=CSF5DZgZerUZ6Bdnt0mfzM-2QEUwnvC_JeveE7ngtTs,2024
|
49
50
|
math_spec_mapping/Reports/html.py,sha256=MCVp_D1LuRoZrHtwzFOJGQviztGeahqsWf3Zue1Yz64,10134
|
50
51
|
math_spec_mapping/Reports/markdown.py,sha256=2WYZYzIubtNb-OyZCOK5nS_O9jPOsdwAtMMJJOt-ZDk,30657
|
51
52
|
math_spec_mapping/Reports/mechanisms.py,sha256=d2Rxt3JBYvqAOAYUynl0buYVoXEHrO8EGq7GK6hK8NA,1322
|
@@ -56,8 +57,8 @@ math_spec_mapping/Reports/spaces.py,sha256=-76hR5wQBv4lsG000ypBJ-OprjsNjI-rNRMYd
|
|
56
57
|
math_spec_mapping/Reports/state.py,sha256=QYeCvX5cHeZBrbvMeDsTqJcUDTuDFJSLvPbasjLspk8,3643
|
57
58
|
math_spec_mapping/Reports/tables.py,sha256=O0CNuqh3LMECq5uLjBOoxMUk5hUvkUK660FNnwWUxDY,1505
|
58
59
|
math_spec_mapping/Reports/wiring.py,sha256=u9SvKWy6T-WJUEgFI6-zgZanoOaTTs_2YwmEceDLsV8,1618
|
59
|
-
math_spec_mapping-0.4.
|
60
|
-
math_spec_mapping-0.4.
|
61
|
-
math_spec_mapping-0.4.
|
62
|
-
math_spec_mapping-0.4.
|
63
|
-
math_spec_mapping-0.4.
|
60
|
+
math_spec_mapping-0.4.3.dist-info/LICENSE,sha256=ObyEzSw8kgCaFbEfpu1zP4TrcAKLA0xhqHMZZfyh7N0,1069
|
61
|
+
math_spec_mapping-0.4.3.dist-info/METADATA,sha256=6NFRaAlIrw6h_8802HicQ2P-8KUUrIDAOkWhY6Ys72w,7064
|
62
|
+
math_spec_mapping-0.4.3.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
63
|
+
math_spec_mapping-0.4.3.dist-info/top_level.txt,sha256=AImhn9wgazkdV0a9vfiphtQR8uGe2nq-ZIOp-6yUk9o,18
|
64
|
+
math_spec_mapping-0.4.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|