math-spec-mapping 0.2.3__py3-none-any.whl → 0.2.5__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.
Classes/Block.py CHANGED
@@ -21,6 +21,7 @@ class Block:
21
21
  self.called_by = []
22
22
  self.calls = []
23
23
  self.block_type = "Block"
24
+ self.all_updates = []
24
25
  # Will be overwritten in composite blocks to represent individual components
25
26
  self.domain_blocks = tuple(
26
27
  [
@@ -61,14 +62,95 @@ class Block:
61
62
  for _ in range(len([x for x in self.codomain if x == TerminatingSpace]))
62
63
  )
63
64
 
65
+ self.find_all_spaces_used(data)
66
+
64
67
  def render_mermaid(self, i):
65
68
  i += 1
66
- return "X{}[{}]".format(i, self.name), i
69
+ out = 'X{}["{}"]'.format(i, self.name)
70
+ if self.block_type == "Mechanism":
71
+ for u in self.updates:
72
+ out += "\n"
73
+ out += "X{} --> {}".format(
74
+ i,
75
+ (u[0].name + "-" + u[1].name).replace(" ", "-"),
76
+ )
77
+ return out, i
78
+
79
+ def render_ending_entities(self):
80
+ if self.block_type == "Mechanism":
81
+ updates = self.updates
82
+ elif self.block_type in ["Parallel Block", "Stack Block", "Split Block"]:
83
+ updates = self.all_updates
84
+ else:
85
+ return "\n", {}
86
+
87
+ out = "\n"
88
+ out += 'subgraph SVS["State Variables"]\n'
89
+
90
+ # Render the entities
91
+ entity_mapping = {}
92
+ entities = set([x[0] for x in updates])
93
+ for i, x in enumerate(entities):
94
+ entity_mapping[x.name] = "EE{}".format(i)
95
+ out += '{}[("{}")]'.format(entity_mapping[x.name], x.name)
96
+ out += "\n"
97
+
98
+ entity_variable_mapping = {}
99
+ # Render the state variables
100
+ for i, x in enumerate(updates):
101
+ entity_variable_mapping[(x[0].name + "-" + x[1].name).replace(" ", "-")] = (
102
+ "EES{}".format(i)
103
+ )
104
+ out += '{}(["{}"])'.format("EES{}".format(i), x[1].name)
105
+ out += "\n"
106
+
107
+ out += "{} --- {}".format("EES{}".format(i), entity_mapping[x[0].name])
108
+ out += "\n"
109
+ out += "end\n"
110
+ out += "\n"
111
+ return out, entity_variable_mapping
67
112
 
68
113
  def render_mermaid_root(self):
69
114
  out = """```mermaid\ngraph TB\n"""
115
+ add, entity_variable_mapping = self.render_ending_entities()
116
+ out += add
70
117
  out += self.render_mermaid(0)[0]
118
+
119
+ for key in entity_variable_mapping:
120
+ out = out.replace(key, entity_variable_mapping[key])
71
121
  out += "\n```"
122
+
123
+ return out
124
+
125
+ def find_all_spaces_used(self, data):
126
+ self.all_spaces_used = []
127
+ self.all_spaces_used.extend(self.domain)
128
+ self.all_spaces_used.extend(self.codomain)
129
+ if "components" in data:
130
+ for x in data["components"]:
131
+ self.all_spaces_used.extend(x.all_spaces_used)
132
+ self.all_spaces_used = list(set(self.all_spaces_used))
133
+
134
+ def find_all_updates(self, data):
135
+ self.all_updates = []
136
+ if "components" in data:
137
+ for x in data["components"]:
138
+ if x.block_type == "Mechanism":
139
+ self.all_updates.extend(x.updates)
140
+ else:
141
+ self.all_updates.extend(x.all_updates)
142
+ self.all_updates = list(set(self.all_updates))
143
+
144
+ def components_full(self):
145
+ q = [self]
146
+ out = []
147
+ while len(q) > 0:
148
+ cur = q.pop()
149
+ if hasattr(cur, "components"):
150
+ q.extend(cur.components)
151
+ else:
152
+ out.append(cur)
153
+ out = list(set(out))
72
154
  return out
73
155
 
74
156
 
@@ -123,8 +205,9 @@ class ParallelBlock(Block):
123
205
 
124
206
  self.called_by = []
125
207
  self.calls = []
126
- self.block_type = "Paralell Block"
208
+ self.block_type = "Parallel Block"
127
209
  self.metadata = data["metadata"]
210
+ self.find_all_spaces_used(data)
128
211
 
129
212
  def render_mermaid(self, i):
130
213
  multi = None
@@ -139,6 +222,7 @@ class ParallelBlock(Block):
139
222
  # Render components
140
223
  domain_map = {}
141
224
  codomain_map = {}
225
+
142
226
  for component in self.components:
143
227
  domain = component.domain
144
228
  codomain = component.codomain
@@ -182,22 +266,27 @@ class ParallelBlock(Block):
182
266
  for ix1 in nodes:
183
267
  d = domain_map[ix1]
184
268
  if len(d) > 0:
269
+ d_length = len(d)
185
270
  d = "\n".join(d)
186
271
  d = '"{}"'.format(d)
187
- out += "X{} --{}--> X{}".format(domain_i, d, ix1)
272
+ out += "X{} --{}{}-> X{}".format(domain_i, d, "-" * d_length, ix1)
188
273
  else:
189
274
  out += "X{} --> X{}".format(domain_i, ix1)
190
275
  out += "\n"
191
276
 
277
+ codomain_connections = 0
192
278
  for ix1 in nodes:
193
279
  d = codomain_map[ix1]
194
280
  if len(d) > 0:
195
281
  d = "\n".join(d)
196
282
  d = '"{}"'.format(d)
197
283
  out += "X{} --{}--> X{}".format(ix1, d, codomain_i)
198
- else:
199
- out += "X{} --> X{}".format(ix1, codomain_i)
200
- out += "\n"
284
+ codomain_connections += 1
285
+ out += "\n"
286
+ # else:
287
+ # out += "X{} --> X{}".format(ix1, codomain_i)
288
+ if codomain_connections == 0:
289
+ out = out.replace("X{}[Codomain]".format(codomain_i), "")
201
290
 
202
291
  # Subgraph it
203
292
  if self.mermaid_show_name:
@@ -205,7 +294,7 @@ class ParallelBlock(Block):
205
294
  else:
206
295
  name = " "
207
296
  i += 1
208
- out = "subgraph X{}[{}]\ndirection TB\n".format(i, name) + out
297
+ out = 'subgraph X{}["{}"]\ndirection TB\n'.format(i, name) + out
209
298
 
210
299
  out += "end"
211
300
 
@@ -241,6 +330,7 @@ class StackBlock(Block):
241
330
 
242
331
  self.block_type = "Stack Block"
243
332
  self.metadata = data["metadata"]
333
+ self.find_all_spaces_used(data)
244
334
 
245
335
  def _check_domain_mapping(self):
246
336
  x = self.components[:-1]
@@ -340,12 +430,13 @@ class StackBlock(Block):
340
430
  d = domain_map[ix4]
341
431
  optional = global_optional
342
432
  if len(d) > 0:
433
+ d_length = len(d)
343
434
  d = "\n".join(d)
344
435
  d = '"{}"'.format(d)
345
436
  if optional:
346
- out += "X{}-.{}.->X{}".format(ix3, d, ix4)
437
+ out += "X{}-.{}.{}->X{}".format(ix3, d, "." * d_length, ix4)
347
438
  else:
348
- out += "X{}--{}-->X{}".format(ix3, d, ix4)
439
+ out += "X{}--{}-{}->X{}".format(ix3, d, "-" * d_length, ix4)
349
440
  else:
350
441
  if optional:
351
442
  out += "X{}-.->X{}".format(ix3, ix4)
@@ -359,7 +450,7 @@ class StackBlock(Block):
359
450
  else:
360
451
  name = " "
361
452
  i += 1
362
- out = "subgraph X{}[{}]\ndirection TB\n".format(i, name) + out
453
+ out = 'subgraph X{}["{}"]\ndirection TB\n'.format(i, name) + out
363
454
  out += "end"
364
455
 
365
456
  return out, i
@@ -419,6 +510,7 @@ class SplitBlock(Block):
419
510
 
420
511
  self.block_type = "Split Block"
421
512
  self.metadata = data["metadata"]
513
+ self.find_all_spaces_used(data)
422
514
 
423
515
  def render_mermaid(self, i):
424
516
  multi = None
Classes/Policy.py CHANGED
@@ -14,3 +14,4 @@ class Policy(Block):
14
14
  super().__init__(data)
15
15
  self.policy_options: List[PolicyOption] = data["policy_options"]
16
16
  self.block_type = "Policy"
17
+ self.metrics_used = data["metrics_used"]
Convenience/__init__.py CHANGED
@@ -0,0 +1 @@
1
+ from .documentation import write_top_level_json_description
@@ -0,0 +1,49 @@
1
+ from src import schema
2
+
3
+
4
+ def write_json_description(schema, key, name):
5
+ out = "- **{}**: ".format(name)
6
+
7
+ out += schema["definitions"][key]["description"]
8
+ out += "\n"
9
+ return out
10
+
11
+
12
+ def write_top_level_json_description(indent_level):
13
+
14
+ out = "#{} MSML Components".format("#" * indent_level)
15
+ out += "\n\n"
16
+ out += "MSML extends GDS with multiple types of blocks and other enhancements. Below are the definitions of top level components."
17
+ out += "\n\n"
18
+
19
+ out += "##{} Types & Spaces".format("#" * indent_level)
20
+ out += "\n\n"
21
+
22
+ out += write_json_description(schema, "Type", "Type")
23
+ out += write_json_description(schema, "Space", "Space")
24
+
25
+ out += "\n"
26
+
27
+ out += "##{} Entities, States, Parameters & Metrics".format("#" * indent_level)
28
+ out += "\n\n"
29
+
30
+ out += write_json_description(schema, "Entity", "Entity")
31
+ out += write_json_description(schema, "State", "State")
32
+ out += write_json_description(schema, "StatefulMetric", "Stateful Metric")
33
+ out += write_json_description(schema, "Parameter", "Parameter")
34
+ out += write_json_description(schema, "Metric", "Metric")
35
+
36
+ out += "\n"
37
+
38
+ out += "##{} Blocks & Wiring".format("#" * indent_level)
39
+ out += "\n\n"
40
+
41
+ out += write_json_description(schema, "BoundaryAction", "Boundary Action")
42
+ out += write_json_description(schema, "ControlAction", "Control Action")
43
+ out += write_json_description(schema, "Policy", "Policy")
44
+ out += write_json_description(schema, "Mechanism", "Mechanism")
45
+ out += write_json_description(schema, "Wiring", "Wiring")
46
+
47
+ out += "\n"
48
+
49
+ return out
Load/load.py CHANGED
@@ -58,6 +58,14 @@ def load_from_json(json: Dict) -> MathSpec:
58
58
  action_transmission_channels = load_wiring(ms, json)
59
59
  load_action_transmission_channels(ms, action_transmission_channels)
60
60
  load_state_update_transmission_channels(ms, state_update_transmission_channels)
61
+
62
+ temp = {}
63
+ for w in json["Wiring"]:
64
+ temp[w["name"]] = w
65
+ for w in ms["Wiring"]:
66
+ w = temp[w]
67
+ ms["Wiring"][w["name"]].find_all_updates(w)
68
+
61
69
  load_metrics(ms, json, stateful_metrics_map)
62
70
  if "Displays" in json:
63
71
  load_displays(ms, json)
Load/metrics.py CHANGED
@@ -93,3 +93,12 @@ def load_metrics(ms: Dict, json: Dict, stateful_metrics_map) -> None:
93
93
  z in ms["Metrics"] or z in names or z in stateful_metrics_map
94
94
  ), "{} is not defined in the spec".format(z)
95
95
  assert len(metrics) == 0, "There are circular references"
96
+
97
+ # Load the metrics into the policies
98
+ for key in ms["Policies"]:
99
+ policy = ms["Policies"][key]
100
+ hold = policy.metrics_used[:]
101
+ policy.metrics_used = []
102
+ for x in hold:
103
+ assert x in ms["Metrics"], "{} not a valid metric".format(x)
104
+ policy.metrics_used.append(ms["Metrics"][x])
Load/stateful_metrics.py CHANGED
@@ -55,5 +55,9 @@ def load_stateful_metrics(ms: Dict, json: Dict) -> None:
55
55
  """
56
56
 
57
57
  ms["Stateful Metrics"] = {}
58
+ check = []
58
59
  for sm in json["Stateful Metrics"]:
59
60
  ms["Stateful Metrics"][sm["name"]] = convert_stateful_metric(ms, sm)
61
+ for x in ms["Stateful Metrics"][sm["name"]].metrics:
62
+ assert x.name not in check, "{} stateful metric name is repeated"
63
+ check.append(x)
Load/type.py CHANGED
@@ -1,6 +1,7 @@
1
1
  from .general import check_json_keys
2
2
  from ..Classes import Type
3
3
  import os
4
+ from typing import _UnionGenericAlias
4
5
 
5
6
 
6
7
  def convert_type(data, ms):
@@ -32,8 +33,14 @@ def convert_type(data, ms):
32
33
  val = val.__name__
33
34
  out[key] = val
34
35
  data["type_name"]["python"] = str(out)
36
+ elif type(data["type"]["python"]) == _UnionGenericAlias:
37
+ data["type_name"]["python"] = data["type"]["python"].__repr__()
35
38
  else:
36
39
  data["type_name"]["python"] = data["type"]["python"].__name__
40
+ if "typescript" in ms["Type Keys"]:
41
+ if type_name in ms["Type Keys"]["typescript"]:
42
+ data["type"]["typescript"] = ms["Type Keys"]["typescript"][type_name]
43
+ data["type_name"]["typescript"] = ms["Type Keys"]["typescript"][type_name]
37
44
 
38
45
  # Build the type object
39
46
  return Type(data)
@@ -52,10 +59,43 @@ def load_python_type_key():
52
59
  return mapping
53
60
 
54
61
 
62
+ def load_typescript_type_key(path):
63
+ with open(path, "r") as file:
64
+ type_definitions = file.read()
65
+ type_definitions = type_definitions.split("\n")
66
+ type_definitions = [x for x in type_definitions if len(x) > 0]
67
+ hold = type_definitions[:]
68
+ type_definitions = []
69
+ type_definitions.append(hold.pop(0))
70
+ while len(hold) > 0:
71
+ curr = hold.pop(0)
72
+ if "type" in curr or "interface" in curr:
73
+ type_definitions.append(curr)
74
+ else:
75
+ type_definitions[-1] += "\n" + curr
76
+
77
+ hold = type_definitions[:]
78
+ type_definitions = {}
79
+ for x in hold:
80
+ name = x
81
+ if x.startswith("type"):
82
+ name = name[5:]
83
+ elif x.startswith("interface"):
84
+ name = name[10:]
85
+ else:
86
+ assert False
87
+ name = name[: name.index("=")].strip()
88
+ type_definitions[name] = x
89
+ return type_definitions
90
+
91
+
55
92
  def load_type_keys(ms) -> dict:
56
93
  type_keys = {}
57
94
  python_path = "src/TypeMappings/types.py"
95
+ typescript_path = "src/TypeMappings/types.ts"
58
96
  if os.path.exists(python_path):
59
97
  type_keys["python"] = load_python_type_key()
98
+ if os.path.exists(typescript_path):
99
+ type_keys["typescript"] = load_typescript_type_key(typescript_path)
60
100
 
61
101
  ms["Type Keys"] = type_keys
Reports/html.py CHANGED
@@ -111,7 +111,9 @@ def write_entity_reports(ms: MathSpec, directory: str, entities: List[str]) -> N
111
111
  f.write(out)
112
112
 
113
113
 
114
- def write_spec_tree(ms: MathSpec, path=None, linking=False, add_tabbing=False) -> str:
114
+ def write_spec_tree(
115
+ ms: MathSpec, path=None, linking=False, add_tabbing=False, readme=False
116
+ ) -> str:
115
117
  """Write the tree of the specification structure
116
118
 
117
119
  Args:
@@ -145,11 +147,18 @@ def write_spec_tree(ms: MathSpec, path=None, linking=False, add_tabbing=False) -
145
147
  out += symbol1 + "**Stateful Metrics**\n"
146
148
  for name in ms.stateful_metrics.keys():
147
149
  if linking:
148
- out += symbol2 + "[[{}]]".format(name) + "\n"
150
+ out += symbol2 + "{}".format(name) + "\n"
149
151
  else:
150
152
  out += symbol2 + name + "\n"
151
153
  for var in ms.stateful_metrics[name].metrics:
152
- out += symbol3 + var.name + "\n"
154
+ out += symbol3 + "[[{}]]".format(var.name) + "\n"
155
+
156
+ out += symbol1 + "**Types**\n"
157
+ for name in ms.types.keys():
158
+ if linking:
159
+ out += symbol2 + "[[{}]]".format(name) + "\n"
160
+ else:
161
+ out += symbol2 + name + "\n"
153
162
 
154
163
  out += symbol1 + "**Spaces**\n"
155
164
  for name in ms.spaces.keys():
@@ -160,11 +169,11 @@ def write_spec_tree(ms: MathSpec, path=None, linking=False, add_tabbing=False) -
160
169
  out += symbol1 + "**Parameters**\n"
161
170
  for name in ms.parameters.data.keys():
162
171
  if linking:
163
- out += symbol2 + "[[{}]]".format(name) + "\n"
172
+ out += symbol2 + "{}".format(name) + "\n"
164
173
  else:
165
174
  out += symbol2 + name + "\n"
166
175
  for param in [x.name for x in ms.parameters.data[name].parameters]:
167
- out += symbol3 + param + "\n"
176
+ out += symbol3 + "[[{}]]".format(param) + "\n"
168
177
 
169
178
  out += symbol1 + "**Boundary Actions**\n"
170
179
  for name in ms.boundary_actions.keys():
@@ -198,6 +207,9 @@ def write_spec_tree(ms: MathSpec, path=None, linking=False, add_tabbing=False) -
198
207
  out = out.split("\n")
199
208
  out = ["\t" + x for x in out]
200
209
  out = "\n".join(out)
210
+ if readme:
211
+ out = "\n\n```\n{}\n```".format(out)
212
+ out = out.replace("**", "")
201
213
 
202
214
  if path:
203
215
  with open("{}/Spec Tree.md".format(path), "w") as f:
@@ -211,6 +223,6 @@ def write_overview(ms: MathSpec, name: str, file_path: str, summary: str = None)
211
223
  out += "<h2>Summary</h2>"
212
224
  out += "<p>{}</p>".format(summary)
213
225
  out += "<h2>Specification Tree</h2>"
214
- out += write_spec_tree(ms)
226
+ out += write_spec_tree(ms, readme=True)
215
227
  with open(file_path, "w") as f:
216
228
  f.write(out)
Reports/markdown.py CHANGED
@@ -95,6 +95,10 @@ def write_types_markdown_report(ms, path, t, add_metadata=True):
95
95
  out += "### Python Type\n"
96
96
  out += t.type_name["python"]
97
97
  out += "\n"
98
+ if "typescript" in t.type:
99
+ out += "### Typescript Type\n"
100
+ out += t.type_name["typescript"]
101
+ out += "\n"
98
102
  out += "\n"
99
103
  out += "## Notes"
100
104
  out += "\n\n"
@@ -131,6 +135,12 @@ def write_boundary_action_markdown_report(ms, path, boundary_action, add_metadat
131
135
  out += "\n"
132
136
  out += "\n"
133
137
 
138
+ out += "## Followed By\n"
139
+ for i, x in enumerate([x[0] for x in boundary_action.calls]):
140
+ out += "{}. [[{}]]".format(i + 1, x.label)
141
+ out += "\n"
142
+ out += "\n"
143
+
134
144
  out += "## Constraints"
135
145
  for i, x in enumerate(boundary_action.constraints):
136
146
  out += "{}. {}".format(i + 1, x)
@@ -208,6 +218,16 @@ def write_policy_markdown_report(ms, path, policy, add_metadata=True):
208
218
  out += "{}. {}".format(i + 1, x)
209
219
  out += "\n"
210
220
 
221
+ out += "## Parameters Used\n"
222
+ for i, x in enumerate(policy.parameters_used):
223
+ out += "{}. [[{}]]".format(i + 1, x)
224
+ out += "\n"
225
+
226
+ out += "## Metrics Used\n"
227
+ for i, x in enumerate(policy.metrics_used):
228
+ out += "{}. [[{}]]".format(i + 1, x.name)
229
+ out += "\n"
230
+
211
231
  if policy.policy_options:
212
232
  out += "## Policy Options\n"
213
233
  for i, x in enumerate(policy.policy_options):
@@ -296,7 +316,9 @@ def write_space_markdown_report(ms, path, space, add_metadata=True):
296
316
  out += "\n"
297
317
  out += "\n"
298
318
  d = space.schema
299
- d = ",\n".join(["{}: {}".format(a, b.name) for a, b in zip(d.keys(), d.values())])
319
+ d = ",\n".join(
320
+ ["{}: [[{}]]".format(a, b.name) for a, b in zip(d.keys(), d.values())]
321
+ )
300
322
  d = "{" + d + "}"
301
323
  out += d
302
324
  out += "\n"
@@ -326,6 +348,12 @@ def write_control_action_markdown_report(ms, path, control_action, add_metadata=
326
348
  out += control_action.description
327
349
  out += "\n"
328
350
 
351
+ out += "## Followed By\n"
352
+ for i, x in enumerate([x[0] for x in control_action.calls]):
353
+ out += "{}. [[{}]]".format(i + 1, x.label)
354
+ out += "\n"
355
+ out += "\n"
356
+
329
357
  out += "## Constraints"
330
358
  for i, x in enumerate(control_action.constraints):
331
359
  out += "{}. {}".format(i + 1, x)
@@ -390,7 +418,14 @@ def write_wiring_markdown_report(ms, path, wiring, add_metadata=True):
390
418
 
391
419
  out += "\n"
392
420
 
393
- out += "## Constraints"
421
+ out += "## All Blocks\n"
422
+ for i, x in enumerate(wiring.components_full()):
423
+ out += "{}. [[{}]]".format(i + 1, x.name)
424
+ out += "\n"
425
+
426
+ out += "\n"
427
+
428
+ out += "## Constraints\n"
394
429
  for i, x in enumerate(wiring.constraints):
395
430
  out += "{}. {}".format(i + 1, x)
396
431
  out += "\n"
@@ -408,6 +443,12 @@ def write_wiring_markdown_report(ms, path, wiring, add_metadata=True):
408
443
  out += "\n"
409
444
  out += "\n"
410
445
 
446
+ out += "## All Spaces Used\n"
447
+ for i, x in enumerate(wiring.all_spaces_used):
448
+ out += "{}. [[{}]]".format(i + 1, x.name)
449
+ out += "\n"
450
+ out += "\n"
451
+
411
452
  out += "## Parameters Used\n"
412
453
  for i, x in enumerate(wiring.parameters_used):
413
454
  out += "{}. [[{}]]".format(i + 1, x)
@@ -426,6 +467,12 @@ def write_wiring_markdown_report(ms, path, wiring, add_metadata=True):
426
467
  out += "\n"
427
468
  out += "\n"
428
469
 
470
+ out += "## All State Updates\n"
471
+ for i, x in enumerate(wiring.all_updates):
472
+ out += "{}. [[{}]].{}".format(i + 1, x[0].name, x[1].name)
473
+ out += "\n"
474
+ out += "\n"
475
+
429
476
  with open("{}/Wiring/{}.md".format(path, wiring.name), "w") as f:
430
477
  f.write(out)
431
478
 
@@ -482,7 +529,7 @@ def write_stateful_metrics_markdown_report(ms, path, metric, add_metadata=True):
482
529
 
483
530
  out += "## Variables Used\n"
484
531
  for i, x in enumerate(metric.variables_used):
485
- out += "{}. {}.{}".format(i + 1, x[0], x[1])
532
+ out += "{}. [[{}]].{}".format(i + 1, x[0], x[1])
486
533
  out += "\n"
487
534
  out += "\n"
488
535
 
@@ -516,12 +563,18 @@ def write_metrics_markdown_report(ms, path, metric, add_metadata=True):
516
563
  out += "## Parameters Used\n"
517
564
  for i, x in enumerate(metric.parameters_used):
518
565
  out += "{}. [[{}]]".format(i + 1, x)
566
+ var = ms.parameters.parameter_map[x]
567
+ if var.symbol:
568
+ out += " , symbol: {}".format(var.symbol)
519
569
  out += "\n"
520
570
  out += "\n"
521
571
 
522
572
  out += "## Variables Used\n"
523
573
  for i, x in enumerate(metric.variables_used):
524
574
  out += "{}. {}.{}".format(i + 1, x[0], x[1])
575
+ var = ms.state[x[0]].variable_map[x[1]]
576
+ if var.symbol:
577
+ out += " , symbol: {}".format(var.symbol)
525
578
  out += "\n"
526
579
  out += "\n"
527
580
 
@@ -575,7 +628,7 @@ def write_wiring_display_markdown_report(ms, path, wiring, add_metadata=True):
575
628
  out += "\n"
576
629
 
577
630
  out += "## Unique Components Used\n"
578
- components = [set(x.components) for x in wirings]
631
+ components = [set(x.components_full()) for x in wirings]
579
632
  components = set().union(*components)
580
633
  for i, x in enumerate(components):
581
634
  out += "{}. [[{}]]".format(i + 1, x.name)
@@ -610,7 +663,26 @@ def write_wiring_display_markdown_report(ms, path, wiring, add_metadata=True):
610
663
  f.write(out)
611
664
 
612
665
 
613
- def write_all_markdown_reports(ms, path):
666
+ def write_all_markdown_reports(ms, path, clear_folders=False):
667
+ if clear_folders:
668
+ for x in [
669
+ "Metrics",
670
+ "Mechanisms",
671
+ "Types",
672
+ "Control Actions",
673
+ "Spaces",
674
+ ".obsidian",
675
+ "Boundary Actions",
676
+ "Policies",
677
+ "Wiring",
678
+ "States",
679
+ "Parameters",
680
+ "Entities",
681
+ "Stateful Metrics",
682
+ ]:
683
+ if os.path.exists("{}/{}".format(path, x)):
684
+ for y in os.listdir("{}/{}".format(path, x)):
685
+ os.remove("{}/{}/{}".format(path, x, y))
614
686
 
615
687
  # Write entities
616
688
  entities = list(ms.entities.keys())
__init__.py CHANGED
@@ -26,3 +26,4 @@ from .Reports import (
26
26
  write_all_markdown_reports,
27
27
  )
28
28
  from .schema import schema
29
+ from .Convenience import write_top_level_json_description
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: math_spec_mapping
3
- Version: 0.2.3
3
+ Version: 0.2.5
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
@@ -1,7 +1,7 @@
1
- __init__.py,sha256=bWYy9HVSz89bN8y7H7fP7Xrd1TLliPp73zWBUe3KuFE,846
1
+ __init__.py,sha256=RJMgTt0U7VnF0CtTYKCtx3idtAHhHHn54wBJ9WEZJYE,904
2
2
  schema.py,sha256=6mrRqzEnTTSXjb19xJ63MBp0KjKH0s7i6TfT4MkAY9k,233
3
3
  Classes/ActionTransmissionChannel.py,sha256=zWMo5QsgPh5WGIWXl-xOrZNMXYJXmK6Vejw1dQvi0og,246
4
- Classes/Block.py,sha256=ZBGzwMy_mcGGPMjM78n4MT06G-8rtWHfg2O1Fa1ghL4,14058
4
+ Classes/Block.py,sha256=hXQO221IP-TqZm_TwFKfURpEEjZm7L1TPZDCYlaOdho,17302
5
5
  Classes/BoundaryAction.py,sha256=AOENCqCEfpjotnHhzUj_F2SOP0SGpkN1tNPr8Mtl6Tc,476
6
6
  Classes/ControlAction.py,sha256=xaU3_WVeWOoOFX3O86x30_9Eiirfe76KrO3M2kfjcmo,471
7
7
  Classes/Entity.py,sha256=fA0-b128_OHHxfCg4pzqyQV083EYev1HlVpy86S5igg,1226
@@ -9,14 +9,15 @@ Classes/MathSpec.py,sha256=P4FPfv6tpbrY1ytmOQ61hXBey83YoCMgMKOpo6xikxU,13230
9
9
  Classes/Mechanism.py,sha256=7jj6bcPI6H2iv1VZZTlpbG4G2k9s4MYkrH8Sfj9uGM4,324
10
10
  Classes/Metric.py,sha256=AhPgYppOP6q49xvR8S9STxQsXUKJlTWx7wI1LfZEtww,581
11
11
  Classes/Parameter.py,sha256=ZuJ_w0sChvRElJ4sOnXZ2EV4Ell2xXFulKLjVOpgz2E,1237
12
- Classes/Policy.py,sha256=r0m9oCeAYun2ujoEH0BasuknFV4Rsvlu4Obq4TUO8zk,426
12
+ Classes/Policy.py,sha256=HUEooO4Liy7olmHwegb6A-hcreNMNCevl9QKKwOjSik,475
13
13
  Classes/Space.py,sha256=96Cdi8ERkfsgJnh5UyhecKiuU4hWwI6w-i1U1jtwX6A,398
14
14
  Classes/State.py,sha256=Mdn0D21G198f6q13-2tVBYUbnzhRwoDivWpFtH4XJq0,1423
15
15
  Classes/StateUpdateTransmissionChannel.py,sha256=3hBLvD1lE64PkwqksBXAfFWv7foOZzGQLAFQWy42tOA,257
16
16
  Classes/StatefulMetric.py,sha256=UCis1BJ7fsajHHxFF05ZiyDean2D4s4a95uYYW1Mjq4,749
17
17
  Classes/Type.py,sha256=ZDHSiaDixHOxasOJlHbuBsMjZ29O2O5K_nmHOmlO-Ck,228
18
18
  Classes/__init__.py,sha256=_hXyZMJanmIex_W6yCR2H7Jw8iU2JJIf3U7VcvBSOGU,737
19
- Convenience/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
+ Convenience/__init__.py,sha256=-hNZVoaNSgTmZTiyZoMfWyg14xonC3ppz-diQk1VlUY,60
20
+ Convenience/documentation.py,sha256=Jf7-JJIk_vZkNBIGV4bs5LM3B0RVaCCtuwJ164thGfY,1607
20
21
  Convenience/starter.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
22
  Load/__init__.py,sha256=_ga5nHi7U5rY5lCF36_XI9Qmybq4P8R4m5I5mmjLBk8,33
22
23
  Load/action_transmission_channel.py,sha256=9Wer7g2s5SSOcUYuZ0PqSKUVVnW3EvGQJZNXJTwW__0,2561
@@ -25,23 +26,23 @@ Load/control_actions.py,sha256=VmjezReijEqe9cdPHQubGZTGVPsYbMzWfLu5Dfm9WvY,1563
25
26
  Load/displays.py,sha256=ooHWT_OryzEkp7F3LcGywwdLMRJLxuyPK82zJ3gcyN0,414
26
27
  Load/entities.py,sha256=rMD_Pja-zqH1Z14rsO_Ia7dg3BIi5_HoQmqGAoEYofA,1208
27
28
  Load/general.py,sha256=2q6aGKxXhebiHHTZhtACvM4nWIkTben0o5rXuvfv2Vw,4463
28
- Load/load.py,sha256=7vw-dQ6BADQ3dblxhXNvDRkxM9W7zP_epahsmdt1Qkg,2233
29
+ Load/load.py,sha256=VEiZRsiO3QQnw5ZIJ0RQzgQ5hKoWLz6b36Zv9tG-XvI,2405
29
30
  Load/mechanism.py,sha256=aIpMzgQn8f1aywgOHxL5kHQUn1N8K9pmHOVs51bv3Hk,1673
30
- Load/metrics.py,sha256=wj9Auk9jPYyT2dR55_YiMFhmf-wRUN1bYcmT7XytrcE,2939
31
+ Load/metrics.py,sha256=gD68mt0Y5jSgofZUwscV8PFatOMV_LPwYyPrwV9SdtE,3273
31
32
  Load/parameters.py,sha256=aid_vqYub9643s82NDtMAXLRdV9BPQkri5MadA0L0eQ,1334
32
33
  Load/policy.py,sha256=fDBuOe1LWw-6C_xcYtvtx9dpjWoD9GNEumW7bK8QaT0,2077
33
34
  Load/spaces.py,sha256=7zgGA57Te7T4hfuCCDElffiidWgn1lKm5E14e1yjt8M,1116
34
35
  Load/state_update_transmission_channels.py,sha256=FJWp5n4HdtHAfof5BUQ6BnRakljatL2h8dWCapaVSc0,2238
35
- Load/stateful_metrics.py,sha256=Z4S1BWVRfE0cGtcUikJnhmYLKW4k1CurAPrOfjObSKo,1795
36
+ Load/stateful_metrics.py,sha256=uGSTc6x6lld5xptgSUMHrO0Vg0QDRIL14C6zTg33S8o,1977
36
37
  Load/states.py,sha256=cwo29SBAtj1FoQLEb8c0wkSCn038lIgM9RjNiZefUaE,1223
37
- Load/type.py,sha256=OrnxUEbiPaO_qbM457Wfg45RZK0jven8kEBG0qkSBKw,1559
38
+ Load/type.py,sha256=VFwbkI0BQFsof1HzltFL-ZKIRJDqvu4aWNJ3sUSo-UQ,3083
38
39
  Load/wiring.py,sha256=1dR94U5N1W_WI5rL6lYBltH25ZvApB2pIpq9r5Opkug,3083
39
40
  Reports/__init__.py,sha256=W27I6S9Ro1hWeHmnxIokCA06awB__eYey7PvKD4Hc1s,933
40
41
  Reports/boundary_actions.py,sha256=45BPp4QjWdD-3E9ZWwqgj_nI2-YdcI2ZZ19_Qv_K7Qk,1410
41
42
  Reports/control_actions.py,sha256=NksekZKIPFSIkubttFstKFthc5AU9B9PWRLSl9j1wWs,1216
42
43
  Reports/general.py,sha256=WOOn6Wlb8M4fsdN49FlKLwOka6vJPQ9aCUy88TL2ki0,1610
43
- Reports/html.py,sha256=EKuQg7PwhvY0NDZtJj1nVTZeSheez8PDAsj43tdtvio,7737
44
- Reports/markdown.py,sha256=rRg0hb1194_GySapHV5QULY2F1An2WPnMeceOa7Bt-w,18834
44
+ Reports/html.py,sha256=rBnwvWeFgCfP7O8nsBL6hWE63Y1Qd24QyGD2Z7CnZ-8,8094
45
+ Reports/markdown.py,sha256=Z3cD72G5n77AbpT0NO-iytyiL-aGCddHpK_O3zJ8_mQ,21022
45
46
  Reports/mechanisms.py,sha256=d2Rxt3JBYvqAOAYUynl0buYVoXEHrO8EGq7GK6hK8NA,1322
46
47
  Reports/node_map.py,sha256=FdSMDQG16NX6n9sZcH-T5xwsvgjrV9OqBHc9J_VlNK0,3129
47
48
  Reports/parameters.py,sha256=yizNG4lNGrgrlzYYcHMGfXKDFlPw4PMDYshDqZ3YARs,535
@@ -50,8 +51,8 @@ Reports/spaces.py,sha256=-76hR5wQBv4lsG000ypBJ-OprjsNjI-rNRMYdtsYnjQ,579
50
51
  Reports/state.py,sha256=RSHDjzSiUj4ZjReWbkBW7k2njs3Ovp-q0rCC7GBfD-A,2203
51
52
  Reports/tables.py,sha256=O0CNuqh3LMECq5uLjBOoxMUk5hUvkUK660FNnwWUxDY,1505
52
53
  Reports/wiring.py,sha256=u9SvKWy6T-WJUEgFI6-zgZanoOaTTs_2YwmEceDLsV8,1618
53
- math_spec_mapping-0.2.3.dist-info/LICENSE,sha256=ObyEzSw8kgCaFbEfpu1zP4TrcAKLA0xhqHMZZfyh7N0,1069
54
- math_spec_mapping-0.2.3.dist-info/METADATA,sha256=KF7R2dbr_jh2lpQd5aphqDxB9QxeIbq5Dng_h-f7C-Y,5898
55
- math_spec_mapping-0.2.3.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
56
- math_spec_mapping-0.2.3.dist-info/top_level.txt,sha256=DKHirRZ28B4EfLjV3iAU31Sdj6q90EDPTSkRGRZf3uo,49
57
- math_spec_mapping-0.2.3.dist-info/RECORD,,
54
+ math_spec_mapping-0.2.5.dist-info/LICENSE,sha256=ObyEzSw8kgCaFbEfpu1zP4TrcAKLA0xhqHMZZfyh7N0,1069
55
+ math_spec_mapping-0.2.5.dist-info/METADATA,sha256=LuSr9APc07yodCCbrw8ZgyI9P6-V4npJLEUw5Lp6dp4,5898
56
+ math_spec_mapping-0.2.5.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
57
+ math_spec_mapping-0.2.5.dist-info/top_level.txt,sha256=DKHirRZ28B4EfLjV3iAU31Sdj6q90EDPTSkRGRZf3uo,49
58
+ math_spec_mapping-0.2.5.dist-info/RECORD,,