math-spec-mapping 0.2.8__tar.gz → 0.3.1__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. {math-spec-mapping-0.2.8/src/math_spec_mapping.egg-info → math_spec_mapping-0.3.1}/PKG-INFO +1 -1
  2. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/pyproject.toml +1 -1
  3. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Classes/MathSpec.py +189 -4
  4. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Classes/State.py +1 -0
  5. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Load/metrics.py +6 -2
  6. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Load/states.py +2 -0
  7. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Load/type.py +3 -0
  8. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Reports/html.py +4 -1
  9. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Reports/markdown.py +54 -4
  10. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Reports/state.py +2 -0
  11. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/schema.schema.json +6 -3
  12. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1/src/math_spec_mapping.egg-info}/PKG-INFO +1 -1
  13. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/LICENSE +0 -0
  14. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/README.md +0 -0
  15. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/setup.cfg +0 -0
  16. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Classes/ActionTransmissionChannel.py +0 -0
  17. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Classes/Block.py +0 -0
  18. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Classes/BoundaryAction.py +0 -0
  19. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Classes/ControlAction.py +0 -0
  20. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Classes/Entity.py +0 -0
  21. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Classes/Mechanism.py +0 -0
  22. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Classes/Metric.py +0 -0
  23. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Classes/Parameter.py +0 -0
  24. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Classes/Policy.py +0 -0
  25. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Classes/Space.py +0 -0
  26. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Classes/StateUpdateTransmissionChannel.py +0 -0
  27. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Classes/StatefulMetric.py +0 -0
  28. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Classes/Type.py +0 -0
  29. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Classes/__init__.py +0 -0
  30. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Convenience/__init__.py +0 -0
  31. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Convenience/documentation.py +0 -0
  32. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Convenience/starter.py +0 -0
  33. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Load/__init__.py +0 -0
  34. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Load/action_transmission_channel.py +0 -0
  35. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Load/boundary_actions.py +0 -0
  36. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Load/control_actions.py +0 -0
  37. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Load/displays.py +0 -0
  38. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Load/entities.py +0 -0
  39. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Load/general.py +0 -0
  40. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Load/implementations.py +0 -0
  41. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Load/load.py +0 -0
  42. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Load/mechanism.py +0 -0
  43. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Load/parameters.py +0 -0
  44. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Load/policy.py +0 -0
  45. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Load/spaces.py +0 -0
  46. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Load/state_update_transmission_channels.py +0 -0
  47. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Load/stateful_metrics.py +0 -0
  48. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Load/wiring.py +0 -0
  49. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Reports/__init__.py +0 -0
  50. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Reports/boundary_actions.py +0 -0
  51. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Reports/control_actions.py +0 -0
  52. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Reports/general.py +0 -0
  53. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Reports/mechanisms.py +0 -0
  54. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Reports/node_map.py +0 -0
  55. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Reports/parameters.py +0 -0
  56. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Reports/policies.py +0 -0
  57. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Reports/spaces.py +0 -0
  58. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Reports/tables.py +0 -0
  59. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/Reports/wiring.py +0 -0
  60. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/__init__.py +0 -0
  61. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping/schema.py +0 -0
  62. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping.egg-info/SOURCES.txt +0 -0
  63. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping.egg-info/dependency_links.txt +0 -0
  64. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/src/math_spec_mapping.egg-info/requires.txt +0 -0
  65. {math-spec-mapping-0.2.8 → math_spec_mapping-0.3.1}/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.2.8
3
+ Version: 0.3.1
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.2.8"
6
+ version = "0.3.1"
7
7
  authors = [
8
8
  { name="Sean McOwen", email="Sean@Block.Science" },
9
9
  ]
@@ -6,6 +6,7 @@ from .ControlAction import ControlAction
6
6
  from .BoundaryAction import BoundaryAction
7
7
  import os
8
8
  from copy import deepcopy
9
+ import shutil
9
10
 
10
11
 
11
12
  class MathSpec:
@@ -356,24 +357,31 @@ class MathSpec:
356
357
  return sm
357
358
 
358
359
  def _build_functional_parameters(self):
359
- opts = [x for x in self.policies.values() if len(x.policy_options) > 1]
360
+ opts = [
361
+ (x, x.policy_options)
362
+ for x in self.policies.values()
363
+ if len(x.policy_options) > 1
364
+ ]
360
365
  opts.extend(
361
366
  [
362
- x
367
+ (x, x.boundary_actions)
363
368
  for x in self.boundary_actions.values()
364
369
  if len(x.boundary_action_options) > 1
365
370
  ]
366
371
  )
367
372
  opts.extend(
368
373
  [
369
- x
374
+ (x, x.control_actions)
370
375
  for x in self.control_actions.values()
371
376
  if len(x.control_action_options) > 1
372
377
  ]
373
378
  )
374
379
  self.functional_parameters = {}
375
380
  for x in opts:
376
- self.functional_parameters["FP {}".format(x.name)] = x
381
+ x, y = x
382
+ self.functional_parameters["FP {}".format(x.name)] = {}
383
+ for y1 in y:
384
+ self.functional_parameters["FP {}".format(x.name)][y1.name] = y1
377
385
 
378
386
  def _build_parameter_types(self):
379
387
  system_parameters_types = {}
@@ -596,7 +604,184 @@ class MathSpec:
596
604
  with open(path, "w") as f:
597
605
  f.write(out)
598
606
 
607
+ def metaprogramming_julia_types(self, model_directory, overwrite=False):
608
+ path = model_directory + "/types.jl"
609
+ if not overwrite:
610
+ assert "types.jl" not in os.listdir(
611
+ model_directory
612
+ ), "The types file is already written, either delete it or switch to overwrite mode"
613
+
614
+ shutil.copyfile("src/TypeMappings/types.jl", path)
615
+
616
+ def metaprogramming_julia_spaces(
617
+ self, model_directory, cadCAD_path, overwrite=False
618
+ ):
619
+ path = model_directory + "/spaces.jl"
620
+ if not overwrite:
621
+ assert "spaces.jl" not in os.listdir(
622
+ model_directory
623
+ ), "The spaces file is already written, either delete it or switch to overwrite mode"
624
+
625
+ out = """include("{}")
626
+ include("types.jl")
627
+ using .Spaces: generate_space_type
628
+
629
+ """.format(
630
+ cadCAD_path
631
+ )
632
+
633
+ for space in self.spaces:
634
+ name = self.spaces[space].name
635
+ schema = self.spaces[space].schema
636
+ schema = ["{}={}".format(x, schema[x].original_type_name) for x in schema]
637
+ if len(schema) >= 1:
638
+ schema = ", ".join(schema) + ","
639
+ out += 'generate_space_type(({}), "{}")'.format(schema, name)
640
+ out += "\n"
641
+ # out += "{} = Spaces.{}".format(name, name)
642
+
643
+ with open(path, "w") as f:
644
+ f.write(out)
645
+
646
+ def build_implementation(self, params):
647
+ return MathSpecImplementation(self, params)
648
+
599
649
 
600
650
  class MathSpecImplementation:
601
651
  def __init__(self, ms: MathSpec, params):
602
652
  self.ms = deepcopy(ms)
653
+ self.params = params
654
+ self.control_actions = self.load_control_actions()
655
+ self.boundary_actions = {}
656
+ self.policies = self.load_policies()
657
+ self.mechanisms = self.load_mechanisms()
658
+ self.load_wiring()
659
+
660
+ def load_control_actions(self):
661
+ control_actions = {}
662
+ for ca in self.ms.control_actions:
663
+ ca = self.ms.control_actions[ca]
664
+ opts = ca.control_action_options
665
+ if len(opts) == 0:
666
+ print("{} has no control action options".format(ca.name))
667
+ else:
668
+ if len(opts) == 1:
669
+ opt = opts[0]
670
+ else:
671
+ assert (
672
+ "FP {}".format(ca.name) in self.params
673
+ ), "No functional parameterization for {}".format(ca.name)
674
+ opt = self.ms.functional_parameters["FP {}".format(ca.name)][
675
+ self.params["FP {}".format(ca.name)]
676
+ ]
677
+
678
+ assert (
679
+ "python" in opt.implementations
680
+ ), "No python implementation for {} / {}".format(ca.name, opt.name)
681
+
682
+ control_actions[ca.name] = opt.implementations["python"]
683
+ return control_actions
684
+
685
+ def load_mechanisms(self):
686
+ mechanisms = {}
687
+ for m in self.ms.mechanisms:
688
+ m = self.ms.mechanisms[m]
689
+ if "python" not in m.implementations:
690
+ print("No python implementation for {}".format(m.name))
691
+ else:
692
+ mechanisms[m.name] = m.implementations["python"]
693
+ return mechanisms
694
+
695
+ def load_single_wiring(self, wiring):
696
+ components = [x.name for x in wiring.components]
697
+ if wiring.block_type == "Stack Block":
698
+
699
+ def wiring(state, params, spaces):
700
+ for component in components:
701
+ spaces = self.blocks[component](state, params, spaces)
702
+ return spaces
703
+
704
+ elif wiring.block_type == "Parallel Block":
705
+
706
+ spaces_mapping = {}
707
+ for x in wiring.components:
708
+ spaces_mapping[x.name] = []
709
+
710
+ for i, x in enumerate([x.name for x in wiring.domain_blocks]):
711
+ spaces_mapping[x].append(i)
712
+
713
+ def wiring(state, params, spaces):
714
+ codomain = []
715
+ for component in components:
716
+ spaces_i = [spaces[i] for i in spaces_mapping[component]]
717
+ spaces_i = self.blocks[component](state, params, spaces_i)
718
+ if spaces_i:
719
+ codomain.extend(spaces_i)
720
+ return codomain
721
+
722
+ else:
723
+ assert False
724
+
725
+ return wiring
726
+
727
+ def load_policies(self):
728
+ policies = {}
729
+ for p in self.ms.policies:
730
+ p = self.ms.policies[p]
731
+ opts = p.policy_options
732
+ if len(opts) == 0:
733
+ print("{} has no policy options".format(p.name))
734
+ else:
735
+ if len(opts) == 1:
736
+ opt = opts[0]
737
+ else:
738
+ assert (
739
+ "FP {}".format(p.name) in self.params
740
+ ), "No functional parameterization for {}".format(p.name)
741
+ opt = self.ms.functional_parameters["FP {}".format(p.name)][
742
+ self.params["FP {}".format(p.name)]
743
+ ]
744
+
745
+ if "python" not in opt.implementations:
746
+ print(
747
+ "No python implementation for {} / {}".format(p.name, opt.name)
748
+ )
749
+ else:
750
+ policies[p.name] = opt.implementations["python"]
751
+ return policies
752
+
753
+ def load_wiring(
754
+ self,
755
+ ):
756
+ self.blocks = {}
757
+ self.blocks.update(self.boundary_actions)
758
+ self.blocks.update(self.control_actions)
759
+ self.blocks.update(self.policies)
760
+ self.blocks.update(self.mechanisms)
761
+
762
+ self.wiring = {}
763
+
764
+ wiring = [x for x in self.ms.wiring.values()]
765
+
766
+ i = 1
767
+ while i > 0:
768
+ i = 0
769
+ hold = []
770
+ for w in wiring:
771
+ components = [x.name for x in w.components]
772
+ if all([x in self.blocks for x in components]):
773
+ i += 1
774
+ w2 = self.load_single_wiring(w)
775
+ assert w.name not in self.blocks, "{} was a repeated block".format(
776
+ w.name
777
+ )
778
+ if w2:
779
+ self.blocks[w.name] = w2
780
+ self.wiring[w.name] = w2
781
+
782
+ else:
783
+ hold.append(w)
784
+ wiring = hold
785
+ if len(wiring) > 0:
786
+ wiring = [x.name for x in wiring]
787
+ print("The following wirings were not loading: {}".format(wiring))
@@ -45,6 +45,7 @@ class StateVariable:
45
45
  self.symbol = data["symbol"]
46
46
  self.domain = data["domain"]
47
47
  self.updated_by = []
48
+ self.metadata = data["metadata"]
48
49
 
49
50
  # Add check for type of List
50
51
  if hasattr(self.type, "_name"):
@@ -100,5 +100,9 @@ def load_metrics(ms: Dict, json: Dict, stateful_metrics_map) -> None:
100
100
  hold = policy.metrics_used[:]
101
101
  policy.metrics_used = []
102
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])
103
+ assert (
104
+ x in ms["Metrics"] or x in stateful_metrics_map
105
+ ), "{} not a valid metric or stateful metric".format(x)
106
+ policy.metrics_used.append(
107
+ ms["Metrics"][x] if x in ms["Metrics"] else stateful_metrics_map[x]
108
+ )
@@ -27,6 +27,8 @@ def convert_state(ms, data: Dict) -> State:
27
27
  check_json_keys(var, "State Variable")
28
28
  assert var["type"] in ms["Types"], "Type not in ms"
29
29
  var["type"] = ms["Types"][var["type"]]
30
+ if "metadata" not in var:
31
+ var["metadata"] = {}
30
32
  new_variables.append(StateVariable(var))
31
33
  data["variables"] = new_variables
32
34
 
@@ -111,6 +111,9 @@ def load_julia_type_key(path):
111
111
  elif x.startswith("struct"):
112
112
  name = name[7:]
113
113
  name = name[: name.index("\n")].strip()
114
+ if x.startswith("const"):
115
+ name = name[6:]
116
+ name = name[: name.index("=")].strip()
114
117
  else:
115
118
  assert False
116
119
 
@@ -152,7 +152,10 @@ cssclasses:
152
152
  else:
153
153
  out += symbol2 + name + "\n"
154
154
  for var in ms.state[name].variable_map.keys():
155
- out += symbol3 + var + "\n"
155
+ if linking:
156
+ out += symbol3 + "[[{}-{}\|{}]]".format(name, var, var) + "\n"
157
+ else:
158
+ out += symbol3 + var + "\n"
156
159
 
157
160
  out += symbol1 + "**Stateful Metrics**\n"
158
161
  for name in ms.stateful_metrics.keys():
@@ -145,7 +145,7 @@ def write_boundary_action_markdown_report(ms, path, boundary_action, add_metadat
145
145
  out += "\n"
146
146
  out += "\n"
147
147
 
148
- out += "## Constraints"
148
+ out += "## Constraints\n"
149
149
  for i, x in enumerate(boundary_action.constraints):
150
150
  out += "{}. {}".format(i + 1, x)
151
151
  out += "\n"
@@ -179,6 +179,8 @@ def write_policy_markdown_report(ms, path, policy, add_metadata=True):
179
179
  policy = ms.policies[policy]
180
180
  if "Policies" not in os.listdir(path):
181
181
  os.makedirs(path + "/Policies")
182
+
183
+ out = ""
182
184
  if add_metadata:
183
185
  metadata = policy.metadata
184
186
  if len(metadata) > 0:
@@ -188,7 +190,7 @@ def write_policy_markdown_report(ms, path, policy, add_metadata=True):
188
190
  """.format(
189
191
  "\n".join(["{}: {}".format(x, metadata[x]) for x in metadata])
190
192
  )
191
- out = ""
193
+
192
194
  out += "## Description"
193
195
  out += "\n"
194
196
  out += "\n"
@@ -292,7 +294,9 @@ def write_mechanism_markdown_report(ms, path, mechanism, add_metadata=True):
292
294
  out += "\n\n"
293
295
  out += "## Updates\n\n"
294
296
  for i, x in enumerate(mechanism.updates):
295
- out += "{}. [[{}]].{}".format(i + 1, x[0].name, x[1].name)
297
+ out += "{}. [[{}]].[[{}|{}]]".format(
298
+ i + 1, x[0].name, x[0].state.name + "-" + x[1].name, x[1].name
299
+ )
296
300
  out += "\n"
297
301
 
298
302
  with open("{}/Mechanisms/{}.md".format(path, mechanism.label), "w") as f:
@@ -472,8 +476,14 @@ def write_wiring_markdown_report(ms, path, wiring, add_metadata=True):
472
476
  out += "\n"
473
477
 
474
478
  out += "## All State Updates\n"
479
+
475
480
  for i, x in enumerate(wiring.all_updates):
476
- out += "{}. [[{}]].{}".format(i + 1, x[0].name, x[1].name)
481
+ out += "{}. [[{}]].[[{}|{}]]".format(
482
+ i + 1,
483
+ x[0].name,
484
+ ms.entities[x[0].name].state.name + "-" + x[1].name,
485
+ x[1].name,
486
+ )
477
487
  out += "\n"
478
488
  out += "\n"
479
489
 
@@ -608,6 +618,45 @@ def write_displays_markdown_reports(ms, path, add_metadata=True):
608
618
  )
609
619
 
610
620
 
621
+ def write_state_variables_markdown_reports(ms, path, state, add_metadata=True):
622
+ if "State Variables" not in os.listdir(path):
623
+ os.makedirs(path + "/State Variables")
624
+ state = ms.state[state]
625
+ for variable in state.variables:
626
+ out = ""
627
+ if add_metadata:
628
+ metadata = variable.metadata
629
+ if len(metadata) > 0:
630
+ out += """---
631
+ {}
632
+ ---
633
+ """.format(
634
+ "\n".join(["{}: {}".format(x, metadata[x]) for x in metadata])
635
+ )
636
+ out += "Description: "
637
+ out += variable.description
638
+ out += "\n\n"
639
+ out += "Type: [["
640
+ out += variable.type.name
641
+ out += "]]\n\n"
642
+ out += "Symbol: "
643
+ if variable.symbol:
644
+ out += variable.symbol
645
+ out += "\n\n"
646
+ out += "Domain: "
647
+ if variable.domain:
648
+ out += variable.domain
649
+ out += "\n\n"
650
+
651
+ with open(
652
+ "{}/State Variables/{}.md".format(
653
+ path, "{}-{}".format(state.name, variable.name)
654
+ ),
655
+ "w",
656
+ ) as f:
657
+ f.write(out)
658
+
659
+
611
660
  def write_wiring_display_markdown_report(ms, path, wiring, add_metadata=True):
612
661
  wirings = [ms.wiring[w] for w in wiring["components"]]
613
662
  out = ""
@@ -696,6 +745,7 @@ def write_all_markdown_reports(ms, path, clear_folders=False):
696
745
  states = list(ms.state.keys())
697
746
  for x in states:
698
747
  write_state_markdown_report(ms, path, x)
748
+ write_state_variables_markdown_reports(ms, path, x)
699
749
 
700
750
  # Write types
701
751
  for t in ms.types.values():
@@ -51,6 +51,8 @@ def write_state_variable_table_markdown(target_state, links=False):
51
51
  if tv:
52
52
  if links and i == 2:
53
53
  table += "[[{}]]".format(tv)
54
+ elif links and i == 0:
55
+ table += "[[{}-{}\|{}]]".format(target_state.name, tv, tv)
54
56
  else:
55
57
  table += "{}".format(tv)
56
58
  table += "|"
@@ -360,7 +360,8 @@
360
360
  "type": "string"
361
361
  },
362
362
  "description": "All metrics used in implementation of policies"
363
- }
363
+ },
364
+ "metadata": {"type": "object"}
364
365
  },
365
366
  "required": [
366
367
  "codomain",
@@ -390,7 +391,8 @@
390
391
  "logic": {
391
392
  "type": "string",
392
393
  "description": "Any logic associated with the implementation"
393
- }
394
+ },
395
+ "metadata": {"type": "object"}
394
396
  },
395
397
  "required": [
396
398
  "description",
@@ -561,7 +563,8 @@
561
563
  "domain": {
562
564
  "type": ["string","null"],
563
565
  "description": "The mathematical domain of the parameter (optional)"
564
- }
566
+ },
567
+ "metadata": {"type": "object"}
565
568
  },
566
569
  "required": [
567
570
  "description",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: math-spec-mapping
3
- Version: 0.2.8
3
+ Version: 0.3.1
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