math-spec-mapping 0.2.4__py3-none-any.whl → 0.2.5__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
Classes/Block.py CHANGED
@@ -141,6 +141,18 @@ class Block:
141
141
  self.all_updates.extend(x.all_updates)
142
142
  self.all_updates = list(set(self.all_updates))
143
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))
154
+ return out
155
+
144
156
 
145
157
  class ParallelBlock(Block):
146
158
  def __init__(self, data: Dict):
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/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
@@ -37,6 +37,7 @@ def convert_type(data, ms):
37
37
  data["type_name"]["python"] = data["type"]["python"].__repr__()
38
38
  else:
39
39
  data["type_name"]["python"] = data["type"]["python"].__name__
40
+ if "typescript" in ms["Type Keys"]:
40
41
  if type_name in ms["Type Keys"]["typescript"]:
41
42
  data["type"]["typescript"] = ms["Type Keys"]["typescript"][type_name]
42
43
  data["type_name"]["typescript"] = ms["Type Keys"]["typescript"][type_name]
Reports/html.py CHANGED
@@ -147,11 +147,18 @@ def write_spec_tree(
147
147
  out += symbol1 + "**Stateful Metrics**\n"
148
148
  for name in ms.stateful_metrics.keys():
149
149
  if linking:
150
- out += symbol2 + "[[{}]]".format(name) + "\n"
150
+ out += symbol2 + "{}".format(name) + "\n"
151
151
  else:
152
152
  out += symbol2 + name + "\n"
153
153
  for var in ms.stateful_metrics[name].metrics:
154
- 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"
155
162
 
156
163
  out += symbol1 + "**Spaces**\n"
157
164
  for name in ms.spaces.keys():
@@ -162,11 +169,11 @@ def write_spec_tree(
162
169
  out += symbol1 + "**Parameters**\n"
163
170
  for name in ms.parameters.data.keys():
164
171
  if linking:
165
- out += symbol2 + "[[{}]]".format(name) + "\n"
172
+ out += symbol2 + "{}".format(name) + "\n"
166
173
  else:
167
174
  out += symbol2 + name + "\n"
168
175
  for param in [x.name for x in ms.parameters.data[name].parameters]:
169
- out += symbol3 + param + "\n"
176
+ out += symbol3 + "[[{}]]".format(param) + "\n"
170
177
 
171
178
  out += symbol1 + "**Boundary Actions**\n"
172
179
  for name in ms.boundary_actions.keys():
Reports/markdown.py CHANGED
@@ -135,6 +135,12 @@ def write_boundary_action_markdown_report(ms, path, boundary_action, add_metadat
135
135
  out += "\n"
136
136
  out += "\n"
137
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
+
138
144
  out += "## Constraints"
139
145
  for i, x in enumerate(boundary_action.constraints):
140
146
  out += "{}. {}".format(i + 1, x)
@@ -342,6 +348,12 @@ def write_control_action_markdown_report(ms, path, control_action, add_metadata=
342
348
  out += control_action.description
343
349
  out += "\n"
344
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
+
345
357
  out += "## Constraints"
346
358
  for i, x in enumerate(control_action.constraints):
347
359
  out += "{}. {}".format(i + 1, x)
@@ -406,7 +418,14 @@ def write_wiring_markdown_report(ms, path, wiring, add_metadata=True):
406
418
 
407
419
  out += "\n"
408
420
 
409
- 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"
410
429
  for i, x in enumerate(wiring.constraints):
411
430
  out += "{}. {}".format(i + 1, x)
412
431
  out += "\n"
@@ -510,7 +529,7 @@ def write_stateful_metrics_markdown_report(ms, path, metric, add_metadata=True):
510
529
 
511
530
  out += "## Variables Used\n"
512
531
  for i, x in enumerate(metric.variables_used):
513
- out += "{}. {}.{}".format(i + 1, x[0], x[1])
532
+ out += "{}. [[{}]].{}".format(i + 1, x[0], x[1])
514
533
  out += "\n"
515
534
  out += "\n"
516
535
 
@@ -544,12 +563,18 @@ def write_metrics_markdown_report(ms, path, metric, add_metadata=True):
544
563
  out += "## Parameters Used\n"
545
564
  for i, x in enumerate(metric.parameters_used):
546
565
  out += "{}. [[{}]]".format(i + 1, x)
566
+ var = ms.parameters.parameter_map[x]
567
+ if var.symbol:
568
+ out += " , symbol: {}".format(var.symbol)
547
569
  out += "\n"
548
570
  out += "\n"
549
571
 
550
572
  out += "## Variables Used\n"
551
573
  for i, x in enumerate(metric.variables_used):
552
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)
553
578
  out += "\n"
554
579
  out += "\n"
555
580
 
@@ -603,7 +628,7 @@ def write_wiring_display_markdown_report(ms, path, wiring, add_metadata=True):
603
628
  out += "\n"
604
629
 
605
630
  out += "## Unique Components Used\n"
606
- components = [set(x.components) for x in wirings]
631
+ components = [set(x.components_full()) for x in wirings]
607
632
  components = set().union(*components)
608
633
  for i, x in enumerate(components):
609
634
  out += "{}. [[{}]]".format(i + 1, x.name)
@@ -638,7 +663,26 @@ def write_wiring_display_markdown_report(ms, path, wiring, add_metadata=True):
638
663
  f.write(out)
639
664
 
640
665
 
641
- 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))
642
686
 
643
687
  # Write entities
644
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.4
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=HUM_ziEE40DBy_mG-XFnHjg3MTTO2C5e6ONyZIAy77Q,17000
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
@@ -16,7 +16,8 @@ Classes/StateUpdateTransmissionChannel.py,sha256=3hBLvD1lE64PkwqksBXAfFWv7foOZzG
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
@@ -32,16 +33,16 @@ 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=cKfeLAmYG4hl4mxYA3FvWoQt16ReWrL64H98wgehp6U,3043
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=4wpry61_URAc_LeVemQWowVWGlhMwayjaS3eyUSm0rM,7866
44
- Reports/markdown.py,sha256=j5QYmk9HXZK9mL3LQqJaW7FJ9oqCmBpEfmvtElljiso,19643
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.4.dist-info/LICENSE,sha256=ObyEzSw8kgCaFbEfpu1zP4TrcAKLA0xhqHMZZfyh7N0,1069
54
- math_spec_mapping-0.2.4.dist-info/METADATA,sha256=LuLoWfDUlm2t-bKaYix2Pc6C4Fdzq-jVBJ1meGJKKsc,5898
55
- math_spec_mapping-0.2.4.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
56
- math_spec_mapping-0.2.4.dist-info/top_level.txt,sha256=DKHirRZ28B4EfLjV3iAU31Sdj6q90EDPTSkRGRZf3uo,49
57
- math_spec_mapping-0.2.4.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,,