math-spec-mapping 0.3.14__tar.gz → 0.3.15__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. {math_spec_mapping-0.3.14/src/math_spec_mapping.egg-info → math_spec_mapping-0.3.15}/PKG-INFO +1 -1
  2. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/pyproject.toml +1 -1
  3. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Classes/Block.py +16 -0
  4. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Classes/MathSpec.py +18 -1
  5. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Classes/Policy.py +0 -1
  6. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Classes/Space.py +2 -0
  7. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Load/boundary_actions.py +6 -0
  8. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Load/control_actions.py +7 -0
  9. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Load/load.py +3 -0
  10. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Load/mechanism.py +7 -0
  11. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Load/metrics.py +6 -5
  12. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Load/policy.py +7 -0
  13. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Load/wiring.py +5 -0
  14. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Reports/markdown.py +50 -0
  15. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15/src/math_spec_mapping.egg-info}/PKG-INFO +1 -1
  16. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/LICENSE +0 -0
  17. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/README.md +0 -0
  18. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/setup.cfg +0 -0
  19. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Classes/ActionTransmissionChannel.py +0 -0
  20. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Classes/BoundaryAction.py +0 -0
  21. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Classes/ControlAction.py +0 -0
  22. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Classes/Entity.py +0 -0
  23. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Classes/Mechanism.py +0 -0
  24. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Classes/Metric.py +0 -0
  25. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Classes/Parameter.py +0 -0
  26. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Classes/State.py +0 -0
  27. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Classes/StateUpdateTransmissionChannel.py +0 -0
  28. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Classes/StatefulMetric.py +0 -0
  29. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Classes/Type.py +0 -0
  30. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Classes/__init__.py +0 -0
  31. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Convenience/__init__.py +0 -0
  32. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Convenience/documentation.py +0 -0
  33. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Convenience/github.py +0 -0
  34. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Convenience/starter.py +0 -0
  35. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Load/__init__.py +0 -0
  36. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Load/action_transmission_channel.py +0 -0
  37. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Load/displays.py +0 -0
  38. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Load/entities.py +0 -0
  39. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Load/general.py +0 -0
  40. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Load/implementations.py +0 -0
  41. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Load/parameters.py +0 -0
  42. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Load/spaces.py +0 -0
  43. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Load/state_update_transmission_channels.py +0 -0
  44. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Load/stateful_metrics.py +0 -0
  45. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Load/states.py +0 -0
  46. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Load/type.py +0 -0
  47. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Reports/__init__.py +0 -0
  48. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Reports/boundary_actions.py +0 -0
  49. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Reports/control_actions.py +0 -0
  50. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Reports/general.py +0 -0
  51. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Reports/html.py +0 -0
  52. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Reports/mechanisms.py +0 -0
  53. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Reports/node_map.py +0 -0
  54. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Reports/parameters.py +0 -0
  55. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Reports/policies.py +0 -0
  56. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Reports/spaces.py +0 -0
  57. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Reports/state.py +0 -0
  58. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Reports/tables.py +0 -0
  59. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/Reports/wiring.py +0 -0
  60. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/__init__.py +0 -0
  61. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/schema.py +0 -0
  62. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping/schema.schema.json +0 -0
  63. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping.egg-info/SOURCES.txt +0 -0
  64. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping.egg-info/dependency_links.txt +0 -0
  65. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping.egg-info/requires.txt +0 -0
  66. {math_spec_mapping-0.3.14 → math_spec_mapping-0.3.15}/src/math_spec_mapping.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: math-spec-mapping
3
- Version: 0.3.14
3
+ Version: 0.3.15
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
@@ -3,7 +3,7 @@ requires = ["setuptools>=61.0"]
3
3
  build-backend = "setuptools.build_meta"
4
4
  [project]
5
5
  name = "math-spec-mapping"
6
- version = "0.3.14"
6
+ version = "0.3.15"
7
7
  authors = [
8
8
  { name="Sean McOwen", email="Sean@Block.Science" },
9
9
  ]
@@ -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:
@@ -163,6 +167,10 @@ class ParallelBlock(Block):
163
167
  self.components = data["components"]
164
168
  self.description = data["description"]
165
169
  self.constraints = data["constraints"]
170
+ if "metrics_used" in data:
171
+ self.metrics_used = data["metrics_used"]
172
+ else:
173
+ self.metrics_used = []
166
174
  self.mermaid_show_name = data["mermaid_show_name"]
167
175
  self.domain = tuple(
168
176
  [
@@ -316,6 +324,10 @@ class StackBlock(Block):
316
324
  self.mermaid_show_name = data["mermaid_show_name"]
317
325
  self.optional_indices = data["optional_indices"]
318
326
  self.loop = data["loop"]
327
+ if "metrics_used" in data:
328
+ self.metrics_used = data["metrics_used"]
329
+ else:
330
+ self.metrics_used = []
319
331
  self._check_domain_mapping()
320
332
  self.domain = self.components[0].domain
321
333
  self.codomain = self.components[-1].codomain
@@ -470,6 +482,10 @@ class SplitBlock(Block):
470
482
  self.description = data["description"]
471
483
  self.constraints = data["constraints"]
472
484
  self.mermaid_show_name = data["mermaid_show_name"]
485
+ if "metrics_used" in data:
486
+ self.metrics_used = data["metrics_used"]
487
+ else:
488
+ self.metrics_used = []
473
489
  self.domain = tuple(
474
490
  [
475
491
  i
@@ -32,7 +32,9 @@ class MathSpec:
32
32
  ]
33
33
  self.stateful_metrics = ms_dict["Stateful Metrics"]
34
34
  self.wiring = ms_dict["Wiring"]
35
- self.blocks = ms_dict["Blocks"]
35
+ # self.blocks = ms_dict["Blocks"]
36
+ self._load_blocks()
37
+ self._load_components()
36
38
  self.types = ms_dict["Types"]
37
39
  self.metrics = ms_dict["Metrics"]
38
40
  self.displays = ms_dict["Displays"]
@@ -206,6 +208,21 @@ class MathSpec:
206
208
 
207
209
  return out
208
210
 
211
+ def _load_blocks(self):
212
+ self.blocks = {}
213
+ self.blocks.update(self.control_actions)
214
+ self.blocks.update(self.boundary_actions)
215
+ self.blocks.update(self.policies)
216
+ self.blocks.update(self.mechanisms)
217
+ self.blocks.update(self.wiring)
218
+
219
+ def _load_components(self):
220
+ self.components = {}
221
+ self.components.update(self.control_actions)
222
+ self.components.update(self.boundary_actions)
223
+ self.components.update(self.policies)
224
+ self.components.update(self.mechanisms)
225
+
209
226
  def crawl_action_chains(self, action_keys: List[str]) -> dict:
210
227
  """Crawl the graph of the actions to find all policies, entities, edges, etc.
211
228
 
@@ -15,4 +15,3 @@ class Policy(Block):
15
15
  super().__init__(data)
16
16
  self.policy_options: List[PolicyOption] = data["policy_options"]
17
17
  self.block_type = "Policy"
18
- self.metrics_used = data["metrics_used"]
@@ -7,6 +7,8 @@ class Space:
7
7
  self.schema = data["schema"]
8
8
  self.metadata = data["metadata"]
9
9
  self.name_variable = self.name.replace(" ", "").replace("-", "_")
10
+ self.domain_blocks = []
11
+ self.codomain_blocks = []
10
12
 
11
13
  def __repr__(self):
12
14
  return self.name
@@ -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])
@@ -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["Policies"]:
109
- policy = ms["Policies"][key]
110
- hold = policy.metrics_used[:]
111
- policy.metrics_used = []
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
- policy.metrics_used.append(
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)
@@ -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])
@@ -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)
@@ -157,6 +157,18 @@ def write_boundary_action_markdown_report(ms, path, boundary_action, add_metadat
157
157
  out += "\n"
158
158
  out += "\n"
159
159
 
160
+ out += "## Metrics Used\n"
161
+ for i, x in enumerate(boundary_action.metrics_used):
162
+ out += "{}. [[{}]]".format(i + 1, x.name)
163
+ out += "\n"
164
+ out += "\n"
165
+
166
+ out += "## Parameters Used\n"
167
+ for i, x in enumerate(sorted(boundary_action.parameters_used, key=lambda x: x)):
168
+ out += "{}. [[{}]]".format(i + 1, x)
169
+ out += "\n"
170
+ out += "\n"
171
+
160
172
  if boundary_action.boundary_action_options:
161
173
  out += "## Boundary Action Options:\n"
162
174
  for i, x in enumerate(boundary_action.boundary_action_options):
@@ -288,6 +300,18 @@ def write_mechanism_markdown_report(ms, path, mechanism, add_metadata=True):
288
300
  out += "{}. {}".format(i + 1, x)
289
301
  out += "\n"
290
302
 
303
+ out += "## Metrics Used\n"
304
+ for i, x in enumerate(mechanism.metrics_used):
305
+ out += "{}. [[{}]]".format(i + 1, x.name)
306
+ out += "\n"
307
+ out += "\n"
308
+
309
+ out += "## Parameters Used\n"
310
+ for i, x in enumerate(sorted(mechanism.parameters_used, key=lambda x: x)):
311
+ out += "{}. [[{}]]".format(i + 1, x)
312
+ out += "\n"
313
+ out += "\n"
314
+
291
315
  out += "## Logic\n"
292
316
  out += mechanism.logic
293
317
 
@@ -329,6 +353,20 @@ def write_space_markdown_report(ms, path, space, add_metadata=True):
329
353
  )
330
354
  d = "{" + d + "}"
331
355
  out += d
356
+ out += "\n\n"
357
+
358
+ out += "## Blocks with Space in Domain"
359
+ out += "\n"
360
+ for i, x in enumerate(space.domain_blocks):
361
+ out += "{}. [[{}]]".format(i + 1, x.name)
362
+ out += "\n"
363
+ out += "\n"
364
+
365
+ out += "## Blocks with Space in Codomain"
366
+ out += "\n"
367
+ for i, x in enumerate(space.codomain_blocks):
368
+ out += "{}. [[{}]]".format(i + 1, x.name)
369
+ out += "\n"
332
370
  out += "\n"
333
371
 
334
372
  with open("{}/Spaces/{}.md".format(path, space.name), "w") as f:
@@ -374,6 +412,12 @@ def write_control_action_markdown_report(ms, path, control_action, add_metadata=
374
412
  out += "\n"
375
413
  out += "\n"
376
414
 
415
+ out += "## Metrics Used\n"
416
+ for i, x in enumerate(control_action.metrics_used):
417
+ out += "{}. [[{}]]".format(i + 1, x.name)
418
+ out += "\n"
419
+ out += "\n"
420
+
377
421
  out += "## Parameters Used\n"
378
422
  for i, x in enumerate(sorted(control_action.parameters_used, key=lambda x: x)):
379
423
  out += "{}. [[{}]]".format(i + 1, x)
@@ -463,6 +507,12 @@ def write_wiring_markdown_report(ms, path, wiring, add_metadata=True):
463
507
  out += "\n"
464
508
  out += "\n"
465
509
 
510
+ out += "## Metrics Used\n"
511
+ for i, x in enumerate(wiring.metrics_used):
512
+ out += "{}. [[{}]]".format(i + 1, x.name)
513
+ out += "\n"
514
+ out += "\n"
515
+
466
516
  out += "## Parameters Used\n"
467
517
  for i, x in enumerate(sorted(wiring.parameters_used, key=lambda x: x)):
468
518
  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.14
3
+ Version: 0.3.15
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