math-spec-mapping 0.3.14__py3-none-any.whl → 0.3.16__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/Classes/Block.py +64 -12
- math_spec_mapping/Classes/MathSpec.py +44 -5
- math_spec_mapping/Classes/Policy.py +0 -1
- math_spec_mapping/Classes/Space.py +2 -0
- math_spec_mapping/Load/boundary_actions.py +6 -0
- math_spec_mapping/Load/control_actions.py +7 -0
- math_spec_mapping/Load/load.py +3 -0
- math_spec_mapping/Load/mechanism.py +7 -0
- math_spec_mapping/Load/metrics.py +6 -5
- math_spec_mapping/Load/policy.py +7 -0
- math_spec_mapping/Load/wiring.py +5 -0
- math_spec_mapping/Reports/markdown.py +134 -3
- {math_spec_mapping-0.3.14.dist-info → math_spec_mapping-0.3.16.dist-info}/METADATA +4 -4
- {math_spec_mapping-0.3.14.dist-info → math_spec_mapping-0.3.16.dist-info}/RECORD +17 -17
- {math_spec_mapping-0.3.14.dist-info → math_spec_mapping-0.3.16.dist-info}/WHEEL +1 -1
- {math_spec_mapping-0.3.14.dist-info → math_spec_mapping-0.3.16.dist-info}/LICENSE +0 -0
- {math_spec_mapping-0.3.14.dist-info → math_spec_mapping-0.3.16.dist-info}/top_level.txt +0 -0
@@ -11,6 +11,10 @@ class Block:
|
|
11
11
|
self.codomain = data["codomain"]
|
12
12
|
self.parameters_used = data["parameters_used"]
|
13
13
|
self.metadata = data["metadata"]
|
14
|
+
if "metrics_used" in data:
|
15
|
+
self.metrics_used = data["metrics_used"]
|
16
|
+
else:
|
17
|
+
self.metrics_used = []
|
14
18
|
if "label" in data:
|
15
19
|
self.label = data["label"]
|
16
20
|
else:
|
@@ -65,7 +69,7 @@ class Block:
|
|
65
69
|
|
66
70
|
self.find_all_spaces_used(data)
|
67
71
|
|
68
|
-
def render_mermaid(self, i):
|
72
|
+
def render_mermaid(self, i, go_deep=True):
|
69
73
|
i += 1
|
70
74
|
out = 'X{}["{}"]'.format(i, self.name)
|
71
75
|
if self.block_type == "Mechanism":
|
@@ -83,7 +87,7 @@ class Block:
|
|
83
87
|
elif self.block_type in ["Parallel Block", "Stack Block", "Split Block"]:
|
84
88
|
updates = self.all_updates
|
85
89
|
else:
|
86
|
-
return "\n", {}
|
90
|
+
return "\n", {}, 0
|
87
91
|
updates = sorted(updates, key=lambda x: x[0].name + "-" + x[1].name)
|
88
92
|
|
89
93
|
out = "\n"
|
@@ -111,18 +115,30 @@ class Block:
|
|
111
115
|
out += "\n"
|
112
116
|
out += "end\n"
|
113
117
|
out += "\n"
|
114
|
-
return out, entity_variable_mapping
|
118
|
+
return out, entity_variable_mapping, len(entities)
|
115
119
|
|
116
|
-
def render_mermaid_root(self):
|
120
|
+
def render_mermaid_root(self, go_deep=True):
|
117
121
|
out = """```mermaid\ngraph TB\n"""
|
118
|
-
add, entity_variable_mapping = self.render_ending_entities()
|
122
|
+
add, entity_variable_mapping, n_entities = self.render_ending_entities()
|
119
123
|
out += add
|
120
|
-
|
124
|
+
new, i = self.render_mermaid(0, go_deep=go_deep)
|
125
|
+
out += new
|
121
126
|
|
122
127
|
for key in entity_variable_mapping:
|
123
128
|
out = out.replace(key, entity_variable_mapping[key])
|
124
|
-
out += "\n
|
129
|
+
out += "\n"
|
130
|
+
for x in range(1, i):
|
131
|
+
if (
|
132
|
+
"X{}[Domain]".format(x) not in out
|
133
|
+
and "X{}[Codomain]".format(x) not in out
|
134
|
+
and "subgraph X{}".format(x) not in out
|
135
|
+
):
|
136
|
+
out += "class X{} internal-link;\n".format(x)
|
137
|
+
|
138
|
+
for x in range(n_entities):
|
139
|
+
out += "class EE{} internal-link;\n".format(x)
|
125
140
|
|
141
|
+
out += "\n```"
|
126
142
|
return out
|
127
143
|
|
128
144
|
def find_all_spaces_used(self, data):
|
@@ -163,6 +179,10 @@ class ParallelBlock(Block):
|
|
163
179
|
self.components = data["components"]
|
164
180
|
self.description = data["description"]
|
165
181
|
self.constraints = data["constraints"]
|
182
|
+
if "metrics_used" in data:
|
183
|
+
self.metrics_used = data["metrics_used"]
|
184
|
+
else:
|
185
|
+
self.metrics_used = []
|
166
186
|
self.mermaid_show_name = data["mermaid_show_name"]
|
167
187
|
self.domain = tuple(
|
168
188
|
[
|
@@ -215,7 +235,19 @@ class ParallelBlock(Block):
|
|
215
235
|
self.metadata = data["metadata"]
|
216
236
|
self.find_all_spaces_used(data)
|
217
237
|
|
218
|
-
def render_mermaid(self, i):
|
238
|
+
def render_mermaid(self, i, go_deep=True):
|
239
|
+
if go_deep == "First":
|
240
|
+
go_deep = False
|
241
|
+
elif go_deep == False:
|
242
|
+
i += 1
|
243
|
+
out = 'X{}["{}"]'.format(i, self.name)
|
244
|
+
for u in self.all_updates:
|
245
|
+
out += "\n"
|
246
|
+
out += "X{} --> {}".format(
|
247
|
+
i,
|
248
|
+
(u[0].name + "-" + u[1].name).replace(" ", "-"),
|
249
|
+
)
|
250
|
+
return out, i
|
219
251
|
multi = None
|
220
252
|
if type(i) == list:
|
221
253
|
multi = i
|
@@ -243,7 +275,7 @@ class ParallelBlock(Block):
|
|
243
275
|
if x.name not in ["Empty Space", "Terminating Space"]
|
244
276
|
]
|
245
277
|
|
246
|
-
component, i = component.render_mermaid(i)
|
278
|
+
component, i = component.render_mermaid(i, go_deep=go_deep)
|
247
279
|
out += component
|
248
280
|
out += "\n"
|
249
281
|
domain_map[i] = domain
|
@@ -316,6 +348,10 @@ class StackBlock(Block):
|
|
316
348
|
self.mermaid_show_name = data["mermaid_show_name"]
|
317
349
|
self.optional_indices = data["optional_indices"]
|
318
350
|
self.loop = data["loop"]
|
351
|
+
if "metrics_used" in data:
|
352
|
+
self.metrics_used = data["metrics_used"]
|
353
|
+
else:
|
354
|
+
self.metrics_used = []
|
319
355
|
self._check_domain_mapping()
|
320
356
|
self.domain = self.components[0].domain
|
321
357
|
self.codomain = self.components[-1].codomain
|
@@ -392,7 +428,19 @@ class StackBlock(Block):
|
|
392
428
|
)
|
393
429
|
return channels
|
394
430
|
|
395
|
-
def render_mermaid(self, i):
|
431
|
+
def render_mermaid(self, i, go_deep=True):
|
432
|
+
if go_deep == "First":
|
433
|
+
go_deep = False
|
434
|
+
elif go_deep == False:
|
435
|
+
i += 1
|
436
|
+
out = 'X{}["{}"]'.format(i, self.name)
|
437
|
+
for u in self.all_updates:
|
438
|
+
out += "\n"
|
439
|
+
out += "X{} --> {}".format(
|
440
|
+
i,
|
441
|
+
(u[0].name + "-" + u[1].name).replace(" ", "-"),
|
442
|
+
)
|
443
|
+
return out, i
|
396
444
|
multi = None
|
397
445
|
if type(i) == list:
|
398
446
|
multi = i
|
@@ -411,7 +459,7 @@ class StackBlock(Block):
|
|
411
459
|
for x in domain
|
412
460
|
if x.name not in ["Empty Space", "Terminating Space"]
|
413
461
|
]
|
414
|
-
component, i = component.render_mermaid(i)
|
462
|
+
component, i = component.render_mermaid(i, go_deep=go_deep)
|
415
463
|
domain_map[i] = domain
|
416
464
|
out += component
|
417
465
|
out += "\n"
|
@@ -470,6 +518,10 @@ class SplitBlock(Block):
|
|
470
518
|
self.description = data["description"]
|
471
519
|
self.constraints = data["constraints"]
|
472
520
|
self.mermaid_show_name = data["mermaid_show_name"]
|
521
|
+
if "metrics_used" in data:
|
522
|
+
self.metrics_used = data["metrics_used"]
|
523
|
+
else:
|
524
|
+
self.metrics_used = []
|
473
525
|
self.domain = tuple(
|
474
526
|
[
|
475
527
|
i
|
@@ -519,7 +571,7 @@ class SplitBlock(Block):
|
|
519
571
|
self.metadata = data["metadata"]
|
520
572
|
self.find_all_spaces_used(data)
|
521
573
|
|
522
|
-
def render_mermaid(self, i):
|
574
|
+
def render_mermaid(self, i, go_deep=True):
|
523
575
|
multi = None
|
524
576
|
if type(i) == list:
|
525
577
|
multi = i
|
@@ -8,7 +8,8 @@ import os
|
|
8
8
|
from copy import deepcopy
|
9
9
|
import shutil
|
10
10
|
import pandas as pd
|
11
|
-
from inspect import signature, getsource
|
11
|
+
from inspect import signature, getsource, getfile
|
12
|
+
from IPython.display import display, Markdown
|
12
13
|
|
13
14
|
|
14
15
|
class MathSpec:
|
@@ -32,7 +33,9 @@ class MathSpec:
|
|
32
33
|
]
|
33
34
|
self.stateful_metrics = ms_dict["Stateful Metrics"]
|
34
35
|
self.wiring = ms_dict["Wiring"]
|
35
|
-
self.blocks = ms_dict["Blocks"]
|
36
|
+
# self.blocks = ms_dict["Blocks"]
|
37
|
+
self._load_blocks()
|
38
|
+
self._load_components()
|
36
39
|
self.types = ms_dict["Types"]
|
37
40
|
self.metrics = ms_dict["Metrics"]
|
38
41
|
self.displays = ms_dict["Displays"]
|
@@ -206,6 +209,21 @@ class MathSpec:
|
|
206
209
|
|
207
210
|
return out
|
208
211
|
|
212
|
+
def _load_blocks(self):
|
213
|
+
self.blocks = {}
|
214
|
+
self.blocks.update(self.control_actions)
|
215
|
+
self.blocks.update(self.boundary_actions)
|
216
|
+
self.blocks.update(self.policies)
|
217
|
+
self.blocks.update(self.mechanisms)
|
218
|
+
self.blocks.update(self.wiring)
|
219
|
+
|
220
|
+
def _load_components(self):
|
221
|
+
self.components = {}
|
222
|
+
self.components.update(self.control_actions)
|
223
|
+
self.components.update(self.boundary_actions)
|
224
|
+
self.components.update(self.policies)
|
225
|
+
self.components.update(self.mechanisms)
|
226
|
+
|
209
227
|
def crawl_action_chains(self, action_keys: List[str]) -> dict:
|
210
228
|
"""Crawl the graph of the actions to find all policies, entities, edges, etc.
|
211
229
|
|
@@ -1099,13 +1117,34 @@ class MathSpecImplementation:
|
|
1099
1117
|
|
1100
1118
|
def load_source_files(self):
|
1101
1119
|
self.source_files = {}
|
1102
|
-
|
1120
|
+
self.file_names = {}
|
1121
|
+
for key in self.blocks:
|
1103
1122
|
self.source_files[key] = getsource(self.components[key])
|
1123
|
+
self.file_names[key] = getfile(self.components[key])
|
1104
1124
|
|
1105
|
-
def print_source_code_files(self, keys=None):
|
1125
|
+
def print_source_code_files(self, keys=None, markdown=True):
|
1106
1126
|
if not keys:
|
1107
1127
|
keys = list(self.source_files.keys())
|
1108
1128
|
for key in keys:
|
1129
|
+
# Skip wirings
|
1130
|
+
if key not in self.ms.components:
|
1131
|
+
continue
|
1109
1132
|
print("-" * 20 + key + "-" * 20)
|
1110
|
-
|
1133
|
+
if markdown:
|
1134
|
+
display(
|
1135
|
+
Markdown(
|
1136
|
+
"""```python
|
1137
|
+
{}
|
1138
|
+
```""".format(
|
1139
|
+
self.source_files[key]
|
1140
|
+
)
|
1141
|
+
)
|
1142
|
+
)
|
1143
|
+
else:
|
1144
|
+
print(self.source_files[key])
|
1145
|
+
print("\n")
|
1146
|
+
full_path = self.file_names[key]
|
1147
|
+
print("File path: {}".format(full_path))
|
1148
|
+
relative_path = "./" + os.path.relpath(full_path, os.getcwd())
|
1149
|
+
print("Relative file path: {}".format(relative_path))
|
1111
1150
|
print("\n\n\n")
|
@@ -79,3 +79,9 @@ def load_boundary_actions(ms: Dict, json: Dict) -> None:
|
|
79
79
|
ms["Boundary Actions"][key] = convert_boundary_action(ba, ms)
|
80
80
|
for entity in ms["Boundary Actions"][key].called_by:
|
81
81
|
entity.add_boundary_action(ms["Boundary Actions"][key])
|
82
|
+
|
83
|
+
for space in ms["Boundary Actions"][key].domain:
|
84
|
+
space.domain_blocks.append(ms["Boundary Actions"][key])
|
85
|
+
|
86
|
+
for space in ms["Boundary Actions"][key].codomain:
|
87
|
+
space.codomain_blocks.append(ms["Boundary Actions"][key])
|
@@ -66,3 +66,10 @@ def load_control_actions(ms: Dict, json: Dict) -> None:
|
|
66
66
|
ms["Control Actions"] = {}
|
67
67
|
for ca in json["Control Actions"]:
|
68
68
|
ms["Control Actions"][ca["name"]] = convert_control_action(ca, ms)
|
69
|
+
|
70
|
+
key = ca["name"]
|
71
|
+
for space in ms["Control Actions"][key].domain:
|
72
|
+
space.domain_blocks.append(ms["Control Actions"][key])
|
73
|
+
|
74
|
+
for space in ms["Control Actions"][key].codomain:
|
75
|
+
space.codomain_blocks.append(ms["Control Actions"][key])
|
math_spec_mapping/Load/load.py
CHANGED
@@ -78,4 +78,7 @@ def load_from_json(json: Dict) -> MathSpec:
|
|
78
78
|
check_json_keys(ms, "Math Spec")
|
79
79
|
|
80
80
|
ms = MathSpec(ms, json)
|
81
|
+
for space in ms.spaces.values():
|
82
|
+
space.domain_blocks = list(set(space.domain_blocks))
|
83
|
+
space.codomain_blocks = list(set(space.codomain_blocks))
|
81
84
|
return ms
|
@@ -68,4 +68,11 @@ def load_mechanisms(ms: Dict, json: Dict) -> None:
|
|
68
68
|
for m in json["Mechanisms"]:
|
69
69
|
ms["Mechanisms"][m["name"]], new_channels = convert_mechanism(m, ms)
|
70
70
|
state_update_transmission_channels.extend(new_channels)
|
71
|
+
|
72
|
+
key = m["name"]
|
73
|
+
for space in ms["Mechanisms"][key].domain:
|
74
|
+
space.domain_blocks.append(ms["Mechanisms"][key])
|
75
|
+
|
76
|
+
for space in ms["Mechanisms"][key].codomain:
|
77
|
+
space.codomain_blocks.append(ms["Mechanisms"][key])
|
71
78
|
return state_update_transmission_channels
|
@@ -105,14 +105,15 @@ def load_metrics(ms: Dict, json: Dict, stateful_metrics_map) -> None:
|
|
105
105
|
assert len(metrics) == 0, "There are circular references"
|
106
106
|
|
107
107
|
# Load the metrics into the policies
|
108
|
-
for key in ms["
|
109
|
-
|
110
|
-
hold =
|
111
|
-
|
108
|
+
for key in ms["Blocks"]:
|
109
|
+
block = ms["Blocks"][key]
|
110
|
+
hold = block.metrics_used[:]
|
111
|
+
block.metrics_used = []
|
112
112
|
for x in hold:
|
113
113
|
assert (
|
114
114
|
x in ms["Metrics"] or x in stateful_metrics_map
|
115
115
|
), "{} not a valid metric or stateful metric".format(x)
|
116
|
-
|
116
|
+
block.metrics_used.append(
|
117
117
|
ms["Metrics"][x] if x in ms["Metrics"] else stateful_metrics_map[x]
|
118
118
|
)
|
119
|
+
block.metrics_used = sorted(block.metrics_used, key=lambda x: x.name)
|
math_spec_mapping/Load/policy.py
CHANGED
@@ -92,3 +92,10 @@ def load_policies(ms: Dict, json: Dict) -> None:
|
|
92
92
|
ms["Policies"] = {}
|
93
93
|
for policy in json["Policies"]:
|
94
94
|
ms["Policies"][policy["name"]] = convert_policy(policy, ms)
|
95
|
+
|
96
|
+
key = policy["name"]
|
97
|
+
for space in ms["Policies"][key].domain:
|
98
|
+
space.domain_blocks.append(ms["Policies"][key])
|
99
|
+
|
100
|
+
for space in ms["Policies"][key].codomain:
|
101
|
+
space.codomain_blocks.append(ms["Policies"][key])
|
math_spec_mapping/Load/wiring.py
CHANGED
@@ -24,6 +24,11 @@ def load_single_wiring(data, ms):
|
|
24
24
|
# Map components
|
25
25
|
data["components"] = [ms["Blocks"][x] for x in data["components"]]
|
26
26
|
|
27
|
+
data["metrics_used"] = []
|
28
|
+
for x in data["components"]:
|
29
|
+
data["metrics_used"].extend(x.metrics_used)
|
30
|
+
data["metrics_used"] = list(set(data["metrics_used"]))
|
31
|
+
|
27
32
|
# Map to the correct block
|
28
33
|
if block_type == "Stack":
|
29
34
|
block = StackBlock(data)
|
@@ -1,5 +1,19 @@
|
|
1
1
|
import os
|
2
2
|
from .state import write_state_section
|
3
|
+
from inspect import signature, getsource, getfile
|
4
|
+
|
5
|
+
|
6
|
+
def get_source_code(ms, component_type, implementation_name):
|
7
|
+
if implementation_name in ms.implementations["python"][component_type]:
|
8
|
+
code = ms.implementations["python"][component_type][implementation_name]
|
9
|
+
else:
|
10
|
+
return None
|
11
|
+
source_code = """```python
|
12
|
+
{}```""".format(
|
13
|
+
getsource(code)
|
14
|
+
)
|
15
|
+
file_path = getfile(code)
|
16
|
+
return source_code, file_path
|
3
17
|
|
4
18
|
|
5
19
|
def write_entity_markdown_report(ms, path, entity, add_metadata=True):
|
@@ -157,6 +171,18 @@ def write_boundary_action_markdown_report(ms, path, boundary_action, add_metadat
|
|
157
171
|
out += "\n"
|
158
172
|
out += "\n"
|
159
173
|
|
174
|
+
out += "## Metrics Used\n"
|
175
|
+
for i, x in enumerate(boundary_action.metrics_used):
|
176
|
+
out += "{}. [[{}]]".format(i + 1, x.name)
|
177
|
+
out += "\n"
|
178
|
+
out += "\n"
|
179
|
+
|
180
|
+
out += "## Parameters Used\n"
|
181
|
+
for i, x in enumerate(sorted(boundary_action.parameters_used, key=lambda x: x)):
|
182
|
+
out += "{}. [[{}]]".format(i + 1, x)
|
183
|
+
out += "\n"
|
184
|
+
out += "\n"
|
185
|
+
|
160
186
|
if boundary_action.boundary_action_options:
|
161
187
|
out += "## Boundary Action Options:\n"
|
162
188
|
for i, x in enumerate(boundary_action.boundary_action_options):
|
@@ -167,7 +193,23 @@ def write_boundary_action_markdown_report(ms, path, boundary_action, add_metadat
|
|
167
193
|
|
168
194
|
out += "#### Logic\n"
|
169
195
|
out += x.logic
|
170
|
-
out += "\n
|
196
|
+
out += "\n"
|
197
|
+
|
198
|
+
temp = get_source_code(ms, "boundary_action_options", x.name)
|
199
|
+
if temp:
|
200
|
+
source_code, file_path = temp
|
201
|
+
file_path = os.path.relpath(
|
202
|
+
file_path, "{}/Boundary Actions".format(path)
|
203
|
+
)
|
204
|
+
out += "#### Python Implementation\n"
|
205
|
+
out += source_code
|
206
|
+
out += "\n"
|
207
|
+
out += "Implementation Path (only works if vault is opened at level including the src folder): [{}]({})".format(
|
208
|
+
file_path, file_path
|
209
|
+
)
|
210
|
+
out += "\n"
|
211
|
+
|
212
|
+
out += "\n"
|
171
213
|
|
172
214
|
with open(
|
173
215
|
"{}/Boundary Actions/{}.md".format(path, boundary_action.label), "w"
|
@@ -244,7 +286,21 @@ def write_policy_markdown_report(ms, path, policy, add_metadata=True):
|
|
244
286
|
|
245
287
|
out += "#### Logic\n"
|
246
288
|
out += x.logic
|
247
|
-
out += "\n
|
289
|
+
out += "\n"
|
290
|
+
|
291
|
+
temp = get_source_code(ms, "policies", x.name)
|
292
|
+
if temp:
|
293
|
+
source_code, file_path = temp
|
294
|
+
file_path = os.path.relpath(file_path, "{}/Policies".format(path))
|
295
|
+
out += "#### Python Implementation\n"
|
296
|
+
out += source_code
|
297
|
+
out += "\n"
|
298
|
+
out += "Implementation Path (only works if vault is opened at level including the src folder): [{}]({})".format(
|
299
|
+
file_path, file_path
|
300
|
+
)
|
301
|
+
out += "\n"
|
302
|
+
|
303
|
+
out += "\n"
|
248
304
|
|
249
305
|
with open("{}/Policies/{}.md".format(path, policy.label), "w") as f:
|
250
306
|
f.write(out)
|
@@ -288,6 +344,18 @@ def write_mechanism_markdown_report(ms, path, mechanism, add_metadata=True):
|
|
288
344
|
out += "{}. {}".format(i + 1, x)
|
289
345
|
out += "\n"
|
290
346
|
|
347
|
+
out += "## Metrics Used\n"
|
348
|
+
for i, x in enumerate(mechanism.metrics_used):
|
349
|
+
out += "{}. [[{}]]".format(i + 1, x.name)
|
350
|
+
out += "\n"
|
351
|
+
out += "\n"
|
352
|
+
|
353
|
+
out += "## Parameters Used\n"
|
354
|
+
for i, x in enumerate(sorted(mechanism.parameters_used, key=lambda x: x)):
|
355
|
+
out += "{}. [[{}]]".format(i + 1, x)
|
356
|
+
out += "\n"
|
357
|
+
out += "\n"
|
358
|
+
|
291
359
|
out += "## Logic\n"
|
292
360
|
out += mechanism.logic
|
293
361
|
|
@@ -299,6 +367,20 @@ def write_mechanism_markdown_report(ms, path, mechanism, add_metadata=True):
|
|
299
367
|
)
|
300
368
|
out += "\n"
|
301
369
|
|
370
|
+
temp = get_source_code(ms, "mechanisms", mechanism.name)
|
371
|
+
if temp:
|
372
|
+
source_code, file_path = temp
|
373
|
+
file_path = os.path.relpath(file_path, "{}/Mechanisms".format(path))
|
374
|
+
out += "## Python Implementation\n"
|
375
|
+
out += source_code
|
376
|
+
out += "\n"
|
377
|
+
out += "Implementation Path (only works if vault is opened at level including the src folder): [{}]({})".format(
|
378
|
+
file_path, file_path
|
379
|
+
)
|
380
|
+
out += "\n"
|
381
|
+
|
382
|
+
out += "\n"
|
383
|
+
|
302
384
|
with open("{}/Mechanisms/{}.md".format(path, mechanism.label), "w") as f:
|
303
385
|
f.write(out)
|
304
386
|
|
@@ -329,6 +411,20 @@ def write_space_markdown_report(ms, path, space, add_metadata=True):
|
|
329
411
|
)
|
330
412
|
d = "{" + d + "}"
|
331
413
|
out += d
|
414
|
+
out += "\n\n"
|
415
|
+
|
416
|
+
out += "## Blocks with Space in Domain"
|
417
|
+
out += "\n"
|
418
|
+
for i, x in enumerate(space.domain_blocks):
|
419
|
+
out += "{}. [[{}]]".format(i + 1, x.name)
|
420
|
+
out += "\n"
|
421
|
+
out += "\n"
|
422
|
+
|
423
|
+
out += "## Blocks with Space in Codomain"
|
424
|
+
out += "\n"
|
425
|
+
for i, x in enumerate(space.codomain_blocks):
|
426
|
+
out += "{}. [[{}]]".format(i + 1, x.name)
|
427
|
+
out += "\n"
|
332
428
|
out += "\n"
|
333
429
|
|
334
430
|
with open("{}/Spaces/{}.md".format(path, space.name), "w") as f:
|
@@ -374,6 +470,12 @@ def write_control_action_markdown_report(ms, path, control_action, add_metadata=
|
|
374
470
|
out += "\n"
|
375
471
|
out += "\n"
|
376
472
|
|
473
|
+
out += "## Metrics Used\n"
|
474
|
+
for i, x in enumerate(control_action.metrics_used):
|
475
|
+
out += "{}. [[{}]]".format(i + 1, x.name)
|
476
|
+
out += "\n"
|
477
|
+
out += "\n"
|
478
|
+
|
377
479
|
out += "## Parameters Used\n"
|
378
480
|
for i, x in enumerate(sorted(control_action.parameters_used, key=lambda x: x)):
|
379
481
|
out += "{}. [[{}]]".format(i + 1, x)
|
@@ -390,7 +492,23 @@ def write_control_action_markdown_report(ms, path, control_action, add_metadata=
|
|
390
492
|
|
391
493
|
out += "#### Logic\n"
|
392
494
|
out += x.logic
|
393
|
-
out += "\n
|
495
|
+
out += "\n"
|
496
|
+
|
497
|
+
temp = get_source_code(ms, "control_action_options", x.name)
|
498
|
+
if temp:
|
499
|
+
source_code, file_path = temp
|
500
|
+
file_path = os.path.relpath(
|
501
|
+
file_path, "{}/Control Actions".format(path)
|
502
|
+
)
|
503
|
+
out += "#### Python Implementation\n"
|
504
|
+
out += source_code
|
505
|
+
out += "\n"
|
506
|
+
out += "Implementation Path (only works if vault is opened at level including the src folder): [{}]({})".format(
|
507
|
+
file_path, file_path
|
508
|
+
)
|
509
|
+
out += "\n"
|
510
|
+
|
511
|
+
out += "\n"
|
394
512
|
|
395
513
|
with open("{}/Control Actions/{}.md".format(path, control_action.label), "w") as f:
|
396
514
|
f.write(out)
|
@@ -410,6 +528,13 @@ def write_wiring_markdown_report(ms, path, wiring, add_metadata=True):
|
|
410
528
|
""".format(
|
411
529
|
"\n".join(["{}: {}".format(x, metadata[x]) for x in metadata])
|
412
530
|
)
|
531
|
+
out += "## Wiring Diagram (Zoomed Out)"
|
532
|
+
out += "\n"
|
533
|
+
out += "\n"
|
534
|
+
out += "- For display of only depth of 1 in the components/nested wirings\n"
|
535
|
+
out += wiring.render_mermaid_root(go_deep="First")
|
536
|
+
out += "\n"
|
537
|
+
out += "\n"
|
413
538
|
|
414
539
|
out += "## Wiring Diagram"
|
415
540
|
out += "\n"
|
@@ -463,6 +588,12 @@ def write_wiring_markdown_report(ms, path, wiring, add_metadata=True):
|
|
463
588
|
out += "\n"
|
464
589
|
out += "\n"
|
465
590
|
|
591
|
+
out += "## Metrics Used\n"
|
592
|
+
for i, x in enumerate(wiring.metrics_used):
|
593
|
+
out += "{}. [[{}]]".format(i + 1, x.name)
|
594
|
+
out += "\n"
|
595
|
+
out += "\n"
|
596
|
+
|
466
597
|
out += "## Parameters Used\n"
|
467
598
|
for i, x in enumerate(sorted(wiring.parameters_used, key=lambda x: x)):
|
468
599
|
out += "{}. [[{}]]".format(i + 1, x)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: math-spec-mapping
|
3
|
-
Version: 0.3.
|
3
|
+
Version: 0.3.16
|
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
|
@@ -9,9 +9,9 @@ Classifier: Operating System :: OS Independent
|
|
9
9
|
Requires-Python: >=3.7
|
10
10
|
Description-Content-Type: text/markdown
|
11
11
|
License-File: LICENSE
|
12
|
-
Requires-Dist: graphviz
|
13
|
-
Requires-Dist: ipython
|
14
|
-
Requires-Dist: pandas
|
12
|
+
Requires-Dist: graphviz>=0.20.1
|
13
|
+
Requires-Dist: ipython>=7.7.0
|
14
|
+
Requires-Dist: pandas>=1.4
|
15
15
|
|
16
16
|
# MSML
|
17
17
|
|
@@ -2,16 +2,16 @@ math_spec_mapping/__init__.py,sha256=LvuIbfILQf3UGyHympLJyncfnnpZpEyvN5UDOpi8bWw
|
|
2
2
|
math_spec_mapping/schema.py,sha256=6mrRqzEnTTSXjb19xJ63MBp0KjKH0s7i6TfT4MkAY9k,233
|
3
3
|
math_spec_mapping/schema.schema.json,sha256=hJP2TcV5WPFPmx4u_A5U1xtnpkE1LeYaTeYOXadTot0,30916
|
4
4
|
math_spec_mapping/Classes/ActionTransmissionChannel.py,sha256=zWMo5QsgPh5WGIWXl-xOrZNMXYJXmK6Vejw1dQvi0og,246
|
5
|
-
math_spec_mapping/Classes/Block.py,sha256=
|
5
|
+
math_spec_mapping/Classes/Block.py,sha256=x5eYzuWp6C_n1tUVMxECpdYi4w_Tv0NLyxg0m8pHjMo,19602
|
6
6
|
math_spec_mapping/Classes/BoundaryAction.py,sha256=_rFvEZ4LNxmlM59js4SuQ9n5CgVmITw4YWKs0-q0r-4,560
|
7
7
|
math_spec_mapping/Classes/ControlAction.py,sha256=4AzMSA8fbnUf-fGlvMJXHJFbz32G1h1QVWf2yzrXrLA,493
|
8
8
|
math_spec_mapping/Classes/Entity.py,sha256=fA0-b128_OHHxfCg4pzqyQV083EYev1HlVpy86S5igg,1226
|
9
|
-
math_spec_mapping/Classes/MathSpec.py,sha256=
|
9
|
+
math_spec_mapping/Classes/MathSpec.py,sha256=jOWfO5mx_7RjAy4SF9Faiw-tGEhL2HeyzV9lKk0pVDQ,43432
|
10
10
|
math_spec_mapping/Classes/Mechanism.py,sha256=2sLm3wYBIeTQaMBcsJ9btqIWsbS895Ra8NY6Y9_G_Dg,379
|
11
11
|
math_spec_mapping/Classes/Metric.py,sha256=iQhH4g8Z60QlM22nPX9ytGmidOsZSiSs0KjqwmsScwU,636
|
12
12
|
math_spec_mapping/Classes/Parameter.py,sha256=ZuJ_w0sChvRElJ4sOnXZ2EV4Ell2xXFulKLjVOpgz2E,1237
|
13
|
-
math_spec_mapping/Classes/Policy.py,sha256=
|
14
|
-
math_spec_mapping/Classes/Space.py,sha256=
|
13
|
+
math_spec_mapping/Classes/Policy.py,sha256=Nso8QJMBDeyN66VkZ29nnZ1WjaMnReMn7SxKt_bRngU,481
|
14
|
+
math_spec_mapping/Classes/Space.py,sha256=TpZ5m28xRzPIDZ98IYtdemgyAm34JuWkgBPNyHpEglg,538
|
15
15
|
math_spec_mapping/Classes/State.py,sha256=U40DoF2qlx_k9gvqQiP1S3C9ZLk3cW_-jmJn71TiCxg,1599
|
16
16
|
math_spec_mapping/Classes/StateUpdateTransmissionChannel.py,sha256=3hBLvD1lE64PkwqksBXAfFWv7foOZzGQLAFQWy42tOA,257
|
17
17
|
math_spec_mapping/Classes/StatefulMetric.py,sha256=plMFMAFEk1y2t4DR5lA2SRC9UrYArsx_W33l3mZSdgE,804
|
@@ -23,29 +23,29 @@ math_spec_mapping/Convenience/github.py,sha256=mMOhIH3Nvh_91fNTOPjz1oQq1iDq2m5hN
|
|
23
23
|
math_spec_mapping/Convenience/starter.py,sha256=9dBKU3EHscut2wA6Nx1XUmehrFIdr4dCjP9V1BbTF6s,12567
|
24
24
|
math_spec_mapping/Load/__init__.py,sha256=_ga5nHi7U5rY5lCF36_XI9Qmybq4P8R4m5I5mmjLBk8,33
|
25
25
|
math_spec_mapping/Load/action_transmission_channel.py,sha256=9Wer7g2s5SSOcUYuZ0PqSKUVVnW3EvGQJZNXJTwW__0,2561
|
26
|
-
math_spec_mapping/Load/boundary_actions.py,sha256=
|
27
|
-
math_spec_mapping/Load/control_actions.py,sha256=
|
26
|
+
math_spec_mapping/Load/boundary_actions.py,sha256=cDN0pjkkWfYY3HHmgSrD__-weGD4DXElnG8w1pRc5Lc,2933
|
27
|
+
math_spec_mapping/Load/control_actions.py,sha256=Y9LeEJuVj2OwxdTfnHZ57UV48j6PYCfyQWux4uXp1Mo,2371
|
28
28
|
math_spec_mapping/Load/displays.py,sha256=uQvs0Jhp8-9SXGex8SG3ibxHJu7ahAV3xLeBFbT8QEE,480
|
29
29
|
math_spec_mapping/Load/entities.py,sha256=Ds7VQY_govWEn1vSHYVrLa8IadSNyOQzaCK18JPYPKk,1289
|
30
30
|
math_spec_mapping/Load/general.py,sha256=2q6aGKxXhebiHHTZhtACvM4nWIkTben0o5rXuvfv2Vw,4463
|
31
31
|
math_spec_mapping/Load/implementations.py,sha256=a8YvumnyQvrnCo-o52Rv4yU8D7nmkMrV1iIA15fr6Bw,490
|
32
|
-
math_spec_mapping/Load/load.py,sha256=
|
33
|
-
math_spec_mapping/Load/mechanism.py,sha256=
|
34
|
-
math_spec_mapping/Load/metrics.py,sha256=
|
32
|
+
math_spec_mapping/Load/load.py,sha256=oC-CuqbVqqhWw0kK7iiNKexAB_djgVNbjXSQfTsj2FA,2647
|
33
|
+
math_spec_mapping/Load/mechanism.py,sha256=VRjkR2McsSJh2oq8n9JkeewirdlVjPRA-T5SRSKWPPQ,2293
|
34
|
+
math_spec_mapping/Load/metrics.py,sha256=CcVM0_aN-aPnH5_AyEKzFCJGPbgMb0brw5nECsdNVeU,3936
|
35
35
|
math_spec_mapping/Load/parameters.py,sha256=W4utm7to3s2fo4z3XgLH0TM1agaIad1qfM2I-lLMua4,1393
|
36
|
-
math_spec_mapping/Load/policy.py,sha256=
|
36
|
+
math_spec_mapping/Load/policy.py,sha256=QTIcslHKgdYjjG69cqkJbW20CPvEL-B8R5u51rd2Puo,2697
|
37
37
|
math_spec_mapping/Load/spaces.py,sha256=5nJto38BVMED5KuMXOqavYj8gcSTKiNSTdMOOp5ThTA,1186
|
38
38
|
math_spec_mapping/Load/state_update_transmission_channels.py,sha256=FJWp5n4HdtHAfof5BUQ6BnRakljatL2h8dWCapaVSc0,2238
|
39
39
|
math_spec_mapping/Load/stateful_metrics.py,sha256=3Lq1ZGMaDd5OcGeqR2p5c_znkYw7ETTNPFjUVdZAHKk,2384
|
40
40
|
math_spec_mapping/Load/states.py,sha256=3YurI7eTNkN6nrXRFVrc58wH0VfM22XOuWE07HVpR7Y,1365
|
41
41
|
math_spec_mapping/Load/type.py,sha256=FbViE3wV1o1JTx7mUYyUpAvgIxDKDQYc6Iw50FrZ4nY,4808
|
42
|
-
math_spec_mapping/Load/wiring.py,sha256=
|
42
|
+
math_spec_mapping/Load/wiring.py,sha256=l1FhHNFRMKorn1oiRhsuMDsExcXnUmTjqQt5ElE-Bbk,3258
|
43
43
|
math_spec_mapping/Reports/__init__.py,sha256=P3IuE1wiM1EO_yCSD73D4O0O6j7aVWmiwpKJM58ISEs,1121
|
44
44
|
math_spec_mapping/Reports/boundary_actions.py,sha256=45BPp4QjWdD-3E9ZWwqgj_nI2-YdcI2ZZ19_Qv_K7Qk,1410
|
45
45
|
math_spec_mapping/Reports/control_actions.py,sha256=NksekZKIPFSIkubttFstKFthc5AU9B9PWRLSl9j1wWs,1216
|
46
46
|
math_spec_mapping/Reports/general.py,sha256=WOOn6Wlb8M4fsdN49FlKLwOka6vJPQ9aCUy88TL2ki0,1610
|
47
47
|
math_spec_mapping/Reports/html.py,sha256=RpyQQON8pDnMmfcyxOsm8UAD5Ad8VKnnW-OyOarTmzA,9711
|
48
|
-
math_spec_mapping/Reports/markdown.py,sha256=
|
48
|
+
math_spec_mapping/Reports/markdown.py,sha256=LCc9pbph0vcDvavCAWt1Z4uF2whnS8sVF87Aiyv4o_M,27592
|
49
49
|
math_spec_mapping/Reports/mechanisms.py,sha256=d2Rxt3JBYvqAOAYUynl0buYVoXEHrO8EGq7GK6hK8NA,1322
|
50
50
|
math_spec_mapping/Reports/node_map.py,sha256=FdSMDQG16NX6n9sZcH-T5xwsvgjrV9OqBHc9J_VlNK0,3129
|
51
51
|
math_spec_mapping/Reports/parameters.py,sha256=-ucL71lolqU0xvV7yb0sXl4pFMRl5tXNWdoBfUjLOaQ,1944
|
@@ -54,8 +54,8 @@ math_spec_mapping/Reports/spaces.py,sha256=-76hR5wQBv4lsG000ypBJ-OprjsNjI-rNRMYd
|
|
54
54
|
math_spec_mapping/Reports/state.py,sha256=QYeCvX5cHeZBrbvMeDsTqJcUDTuDFJSLvPbasjLspk8,3643
|
55
55
|
math_spec_mapping/Reports/tables.py,sha256=O0CNuqh3LMECq5uLjBOoxMUk5hUvkUK660FNnwWUxDY,1505
|
56
56
|
math_spec_mapping/Reports/wiring.py,sha256=u9SvKWy6T-WJUEgFI6-zgZanoOaTTs_2YwmEceDLsV8,1618
|
57
|
-
math_spec_mapping-0.3.
|
58
|
-
math_spec_mapping-0.3.
|
59
|
-
math_spec_mapping-0.3.
|
60
|
-
math_spec_mapping-0.3.
|
61
|
-
math_spec_mapping-0.3.
|
57
|
+
math_spec_mapping-0.3.16.dist-info/LICENSE,sha256=ObyEzSw8kgCaFbEfpu1zP4TrcAKLA0xhqHMZZfyh7N0,1069
|
58
|
+
math_spec_mapping-0.3.16.dist-info/METADATA,sha256=Bm-QWdPR6T4sJDJpc8omA2pKf8Zd_QdEOtwYSK9wHNc,6498
|
59
|
+
math_spec_mapping-0.3.16.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
60
|
+
math_spec_mapping-0.3.16.dist-info/top_level.txt,sha256=AImhn9wgazkdV0a9vfiphtQR8uGe2nq-ZIOp-6yUk9o,18
|
61
|
+
math_spec_mapping-0.3.16.dist-info/RECORD,,
|
File without changes
|
File without changes
|