math-spec-mapping 0.1.2__tar.gz → 0.1.3__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/PKG-INFO +1 -1
  2. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/pyproject.toml +1 -1
  3. math_spec_mapping-0.1.3/src/Classes/Space.py +7 -0
  4. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/src/Classes/__init__.py +2 -1
  5. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/src/Load/action_transmission_channel.py +7 -5
  6. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/src/Load/boundary_actions.py +7 -3
  7. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/src/Load/control_actions.py +4 -1
  8. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/src/Load/general.py +1 -0
  9. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/src/Load/mechanism.py +4 -2
  10. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/src/Load/policy.py +5 -2
  11. math_spec_mapping-0.1.3/src/Load/spaces.py +29 -0
  12. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/src/Reports/html.py +2 -2
  13. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/src/Reports/mechanisms.py +4 -4
  14. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/src/Reports/node_map.py +12 -18
  15. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/src/Reports/policies.py +6 -6
  16. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/src/Reports/spaces.py +6 -4
  17. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/src/Reports/state.py +9 -5
  18. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/src/math_spec_mapping.egg-info/PKG-INFO +1 -1
  19. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/src/math_spec_mapping.egg-info/SOURCES.txt +1 -0
  20. math_spec_mapping-0.1.2/src/Load/spaces.py +0 -13
  21. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/LICENSE +0 -0
  22. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/README.md +0 -0
  23. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/setup.cfg +0 -0
  24. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/src/Classes/ActionTransmissionChannel.py +0 -0
  25. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/src/Classes/Block.py +0 -0
  26. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/src/Classes/BoundaryAction.py +0 -0
  27. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/src/Classes/ControlAction.py +0 -0
  28. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/src/Classes/Entity.py +0 -0
  29. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/src/Classes/MathSpec.py +0 -0
  30. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/src/Classes/Mechanism.py +0 -0
  31. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/src/Classes/Parameter.py +0 -0
  32. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/src/Classes/Policy.py +0 -0
  33. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/src/Classes/State.py +0 -0
  34. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/src/Classes/StateUpdateTransmissionChannel.py +0 -0
  35. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/src/Classes/StatefulMetric.py +0 -0
  36. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/src/Convenience/__init__.py +0 -0
  37. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/src/Convenience/starter.py +0 -0
  38. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/src/Load/__init__.py +0 -0
  39. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/src/Load/entities.py +0 -0
  40. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/src/Load/load.py +1 -1
  41. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/src/Load/parameters.py +0 -0
  42. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/src/Load/state_update_transmission_channels.py +0 -0
  43. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/src/Load/stateful_metrics.py +0 -0
  44. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/src/Load/states.py +0 -0
  45. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/src/Reports/__init__.py +0 -0
  46. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/src/Reports/boundary_actions.py +0 -0
  47. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/src/Reports/control_actions.py +0 -0
  48. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/src/Reports/general.py +0 -0
  49. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/src/Reports/parameters.py +0 -0
  50. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/src/Reports/tables.py +0 -0
  51. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/src/__init__.py +0 -0
  52. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/src/math_spec_mapping.egg-info/dependency_links.txt +0 -0
  53. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/src/math_spec_mapping.egg-info/requires.txt +0 -0
  54. {math_spec_mapping-0.1.2 → math_spec_mapping-0.1.3}/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.1.2
3
+ Version: 0.1.3
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.1.2"
6
+ version = "0.1.3"
7
7
  authors = [
8
8
  { name="Sean McOwen", email="Sean@Block.Science" },
9
9
  ]
@@ -0,0 +1,7 @@
1
+ from typing import Dict
2
+
3
+
4
+ class Space:
5
+ def __init__(self, data: Dict):
6
+ self.name = data["name"]
7
+ self.schema = data["schema"]
@@ -8,4 +8,5 @@ from .Parameter import Parameter, ParameterSet, ParameterContainer
8
8
  from .Policy import Policy, PolicyOption
9
9
  from .StateUpdateTransmissionChannel import StateUpdateTransmissionChannel
10
10
  from .StatefulMetric import StatefulMetric, StatefulMetricSet
11
- from .ControlAction import ControlAction, ControlActionOption
11
+ from .ControlAction import ControlAction, ControlActionOption
12
+ from .Space import Space
@@ -3,7 +3,9 @@ from ..Classes import ActionTransmissionChannel
3
3
  from .general import check_json_keys
4
4
 
5
5
 
6
- def convert_action_transmission_channel(data: Dict, ms: Dict) -> ActionTransmissionChannel:
6
+ def convert_action_transmission_channel(
7
+ data: Dict, ms: Dict
8
+ ) -> ActionTransmissionChannel:
7
9
  """Function to convert dictionary to action transmission channel
8
10
 
9
11
  Args:
@@ -20,6 +22,8 @@ def convert_action_transmission_channel(data: Dict, ms: Dict) -> ActionTransmiss
20
22
  # Copy
21
23
  data = data.copy()
22
24
 
25
+ data["space"] = ms["Spaces"][data["space"]]
26
+
23
27
  # Assert that the origin is in the math spec and only once then convert
24
28
  origin = data["origin"]
25
29
  is_boundary = origin in ms["Boundary Actions"]
@@ -46,10 +50,8 @@ def convert_action_transmission_channel(data: Dict, ms: Dict) -> ActionTransmiss
46
50
  data["target"] = ms["Mechanisms"][target]
47
51
 
48
52
  # Add in called by and called here with origin and target
49
- data["origin"].calls.append(
50
- (data["target"], data["optional"], data["space"]))
51
- data["target"].called_by.append(
52
- (data["origin"], data["optional"], data["space"]))
53
+ data["origin"].calls.append((data["target"], data["optional"], data["space"]))
54
+ data["target"].called_by.append((data["origin"], data["optional"], data["space"]))
53
55
 
54
56
  # Build the action transmission channel object
55
57
  return ActionTransmissionChannel(data)
@@ -30,10 +30,13 @@ def convert_boundary_action(data: Dict, ms: Dict) -> BoundaryAction:
30
30
  # Assert that the entities in called_by are in math spec
31
31
  if data["called_by"]:
32
32
  for name in data["called_by"]:
33
- assert name in ms["Entities"], "{} entity not in entities dictionary".format(
34
- name)
33
+ assert (
34
+ name in ms["Entities"]
35
+ ), "{} entity not in entities dictionary".format(name)
35
36
  data["called_by"] = [ms["Entities"][x] for x in data["called_by"]]
36
37
 
38
+ data["codomain"] = (ms["Spaces"][x] for x in data["codomain"])
39
+
37
40
  # Build the boundary action object
38
41
  return BoundaryAction(data)
39
42
 
@@ -49,6 +52,7 @@ def load_boundary_actions(ms: Dict, json: Dict) -> None:
49
52
  ms["Boundary Actions"] = {}
50
53
  for key in json["Boundary Actions"]:
51
54
  ms["Boundary Actions"][key] = convert_boundary_action(
52
- json["Boundary Actions"][key], ms)
55
+ json["Boundary Actions"][key], ms
56
+ )
53
57
  for entity in ms["Boundary Actions"][key].called_by:
54
58
  entity.add_boundary_action(ms["Boundary Actions"][key])
@@ -27,6 +27,8 @@ def convert_control_action(data: Dict, ms: Dict) -> ControlAction:
27
27
  new_cao.append(ControlActionOption(ca))
28
28
  data["control_action_options"] = new_cao
29
29
 
30
+ data["codomain"] = (ms["Spaces"][x] for x in data["codomain"])
31
+
30
32
  # Build the control action object
31
33
  return ControlAction(data)
32
34
 
@@ -42,4 +44,5 @@ def load_control_actions(ms: Dict, json: Dict) -> None:
42
44
  ms["Control Actions"] = {}
43
45
  for key in json["Control Actions"]:
44
46
  ms["Control Actions"][key] = convert_control_action(
45
- json["Control Actions"][key], ms)
47
+ json["Control Actions"][key], ms
48
+ )
@@ -98,6 +98,7 @@ def check_json_keys(json: Dict, check_set_key: str) -> None:
98
98
  "domain",
99
99
  "parameter_class",
100
100
  ],
101
+ "Space": ["name", "schema"],
101
102
  }
102
103
 
103
104
  check_set = check_sets[check_set_key]
@@ -3,7 +3,7 @@ from ..Classes import Mechanism
3
3
  from .general import check_json_keys
4
4
 
5
5
 
6
- def convert_mechanism(data: Dict) -> Mechanism:
6
+ def convert_mechanism(data: Dict, ms: Dict) -> Mechanism:
7
7
  """Function to convert dictionary to mechanism object
8
8
 
9
9
  Args:
@@ -19,6 +19,8 @@ def convert_mechanism(data: Dict) -> Mechanism:
19
19
  # Copy
20
20
  data = data.copy()
21
21
 
22
+ data["domain"] = (ms["Spaces"][x] for x in data["domain"])
23
+
22
24
  # Build the action transmission channel object
23
25
  return Mechanism(data)
24
26
 
@@ -33,4 +35,4 @@ def load_mechanisms(ms: Dict, json: Dict) -> None:
33
35
 
34
36
  ms["Mechanisms"] = {}
35
37
  for key in json["Mechanisms"]:
36
- ms["Mechanisms"][key] = convert_mechanism(json["Mechanisms"][key])
38
+ ms["Mechanisms"][key] = convert_mechanism(json["Mechanisms"][key], ms)
@@ -25,7 +25,7 @@ def convert_policy_options(data: Dict) -> PolicyOption:
25
25
  return PolicyOption(data)
26
26
 
27
27
 
28
- def convert_policy(data: Dict) -> Policy:
28
+ def convert_policy(data: Dict, ms: Dict) -> Policy:
29
29
  """Function to convert dictionary to policy object
30
30
 
31
31
  Args:
@@ -47,6 +47,9 @@ def convert_policy(data: Dict) -> Policy:
47
47
  policy_options.append(convert_policy_options(po))
48
48
  data["policy_options"] = policy_options
49
49
 
50
+ data["codomain"] = (ms["Spaces"][x] for x in data["codomain"])
51
+ data["domain"] = (ms["Spaces"][x] for x in data["domain"])
52
+
50
53
  # Build the policy object
51
54
  return Policy(data)
52
55
 
@@ -61,4 +64,4 @@ def load_policies(ms: Dict, json: Dict) -> None:
61
64
 
62
65
  ms["Policies"] = {}
63
66
  for key in json["Policies"]:
64
- ms["Policies"][key] = convert_policy(json["Policies"][key])
67
+ ms["Policies"][key] = convert_policy(json["Policies"][key], ms)
@@ -0,0 +1,29 @@
1
+ from typing import Dict
2
+ from ..Classes import Space
3
+ from .general import check_json_keys
4
+
5
+
6
+ def convert_space(data: Dict) -> Space:
7
+ # Check the keys are correct
8
+ check_json_keys(data, "Space")
9
+
10
+ # Copy
11
+ data = data.copy()
12
+
13
+ # Build the space object
14
+ return Space(data)
15
+
16
+
17
+ def load_spaces(ms: Dict, json: Dict) -> None:
18
+ """Function to load spaces into the new dictionary
19
+
20
+ Args:
21
+ ms (Dict): MathSpec dictionary
22
+ json (Dict): JSON version of MathSpec to load
23
+ """
24
+
25
+ # Placeholder for now
26
+ ms["Spaces"] = {}
27
+
28
+ for space in json["Spaces"]:
29
+ ms["Spaces"][space["name"]] = convert_space(space)
@@ -54,7 +54,7 @@ def write_action_chain_reports(
54
54
  out += "<h2>State</h2>"
55
55
  out += write_local_state_variable_tables(all_nodes["State"])
56
56
 
57
- out += write_out_spaces(ms, [x.__name__ for x in all_nodes["Spaces"]])
57
+ out += write_out_spaces(ms, [x.name for x in all_nodes["Spaces"]])
58
58
  out += write_out_boundary_actions(
59
59
  ms, [x.name for x in all_nodes["Boundary Actions"]]
60
60
  )
@@ -93,7 +93,7 @@ def write_entity_reports(ms: MathSpec, directory: str, entities: List[str]) -> N
93
93
  out += "<h2>State</h2>"
94
94
  out += write_local_state_variable_tables(all_nodes["State"])
95
95
 
96
- out += write_out_spaces(ms, [x.__name__ for x in all_nodes["Spaces"]])
96
+ out += write_out_spaces(ms, [x.name for x in all_nodes["Spaces"]])
97
97
  out += write_out_boundary_actions(
98
98
  ms, [x.name for x in all_nodes["Boundary Actions"]]
99
99
  )
@@ -15,25 +15,25 @@ def write_out_mechanism(mechanism: Mechanism) -> str:
15
15
  for i, x in enumerate(mechanism.called_by):
16
16
  x = x[0]
17
17
  out += "<p>"
18
- out += "{}. {}".format(i+1, x.name)
18
+ out += "{}. {}".format(i + 1, x.name)
19
19
  out += "</p>"
20
20
 
21
21
  out += "<h4>Domain Spaces:</h4>\n"
22
22
  for i, x in enumerate(mechanism.domain):
23
23
  out += "<p>"
24
- out += "{}. {}".format(i+1, x.__name__)
24
+ out += "{}. {}".format(i + 1, x.name)
25
25
  out += "</p>"
26
26
 
27
27
  out += "<h4>State Updates:</h4>\n"
28
28
  for i, x in enumerate(mechanism.updates):
29
29
  out += "<p>"
30
- out += "{}. {}.{}".format(i+1, x[0].name, x[1].name)
30
+ out += "{}. {}.{}".format(i + 1, x[0].name, x[1].name)
31
31
  out += "</p>"
32
32
 
33
33
  out += "<h4>Constraints:</h4>\n"
34
34
  for i, x in enumerate(mechanism.constraints):
35
35
  out += "<p>"
36
- out += "{}. {}\n".format(i+1, x)
36
+ out += "{}. {}\n".format(i + 1, x)
37
37
  out += "</p>"
38
38
 
39
39
  out += "<h4>Logic:</h4>\n"
@@ -12,24 +12,19 @@ def create_action_chains_graph(ms, action_keys, name):
12
12
  graph.node(entity.name, entity.label, shape="cylinder", color="black")
13
13
 
14
14
  for ba in all_nodes["Boundary Actions"]:
15
- graph.node(ba.name, ba.label, shape="diamond",
16
- color="orange", style='filled')
17
-
15
+ graph.node(ba.name, ba.label, shape="diamond", color="orange", style="filled")
16
+
18
17
  for ca in all_nodes["Control Actions"]:
19
- graph.node(ca.name, ca.label, shape="diamond",
20
- color="yellow", style='filled')
18
+ graph.node(ca.name, ca.label, shape="diamond", color="yellow", style="filled")
21
19
 
22
20
  for p in all_nodes["Policies"]:
23
- graph.node(p.name, p.label, shape="rectangle",
24
- color="red", style='filled')
21
+ graph.node(p.name, p.label, shape="rectangle", color="red", style="filled")
25
22
 
26
23
  for m in all_nodes["Mechanisms"]:
27
- graph.node(m.name, m.label, shape="oval",
28
- color="azure2", style='filled')
24
+ graph.node(m.name, m.label, shape="oval", color="azure2", style="filled")
29
25
 
30
26
  for entity in all_nodes["Entities2"]:
31
- graph.node(entity.name+"_2", entity.label,
32
- shape="cylinder", color="black")
27
+ graph.node(entity.name + "_2", entity.label, shape="cylinder", color="black")
33
28
 
34
29
  for su in all_nodes["State Updates"]:
35
30
  label = "{}.{}".format(su[0].name, su[1].name)
@@ -41,7 +36,7 @@ def create_action_chains_graph(ms, action_keys, name):
41
36
  graph.edge(entity.name, ba.name)
42
37
  for call in ba.calls:
43
38
  optional_flag = call[1]
44
- space = call[2].__name__
39
+ space = call[2].name
45
40
  space = wrap(space, 12)
46
41
  space = "\n".join(space)
47
42
  call = call[0]
@@ -50,7 +45,7 @@ def create_action_chains_graph(ms, action_keys, name):
50
45
  for ca in all_nodes["Control Actions"]:
51
46
  for call in ca.calls:
52
47
  optional_flag = call[1]
53
- space = call[2].__name__
48
+ space = call[2].name
54
49
  space = wrap(space, 12)
55
50
  space = "\n".join(space)
56
51
  call = call[0]
@@ -58,15 +53,14 @@ def create_action_chains_graph(ms, action_keys, name):
58
53
 
59
54
  for p in all_nodes["Policies"]:
60
55
  for call in p.calls:
61
- space = call[2].__name__
56
+ space = call[2].name
62
57
  space = wrap(space, 12)
63
58
  space = "\n".join(space)
64
- #space = "\n".join(space.split(" "))
59
+ # space = "\n".join(space.split(" "))
65
60
  optional_flag = call[1]
66
61
  call = call[0]
67
62
  if optional_flag:
68
- graph.edge(p.name, call.name, style="dashed",
69
- label=space)
63
+ graph.edge(p.name, call.name, style="dashed", label=space)
70
64
  else:
71
65
  graph.edge(p.name, call.name, label=space)
72
66
 
@@ -78,7 +72,7 @@ def create_action_chains_graph(ms, action_keys, name):
78
72
 
79
73
  for su in all_nodes["State Updates"]:
80
74
  label1 = "{}.{}".format(su[0].name, su[1].name)
81
- label2 = su[0].name+"_2"
75
+ label2 = su[0].name + "_2"
82
76
  graph.edge(label1, label2)
83
77
 
84
78
  return graph
@@ -15,39 +15,39 @@ def write_out_policy(policy: Policy) -> str:
15
15
  for i, x in enumerate(policy.called_by):
16
16
  x = x[0]
17
17
  out += "<p>"
18
- out += "{}. {}".format(i+1, x.name)
18
+ out += "{}. {}".format(i + 1, x.name)
19
19
  out += "</p>"
20
20
 
21
21
  out += "<h4>Domain Spaces:</h4>\n"
22
22
  for i, x in enumerate(policy.domain):
23
23
  out += "<p>"
24
- out += "{}. {}".format(i+1, x.__name__)
24
+ out += "{}. {}".format(i + 1, x.name)
25
25
  out += "</p>"
26
26
 
27
27
  out += "<h4>Followed By:</h4>\n"
28
28
  for i, x in enumerate(policy.calls):
29
29
  x = x[0]
30
30
  out += "<p>"
31
- out += "{}. {}".format(i+1, x.name)
31
+ out += "{}. {}".format(i + 1, x.name)
32
32
  out += "</p>"
33
33
 
34
34
  out += "<h4>Codomain Spaces:</h4>\n"
35
35
  for i, x in enumerate(policy.codomain):
36
36
  out += "<p>"
37
- out += "{}. {}".format(i+1, x.__name__)
37
+ out += "{}. {}".format(i + 1, x.name)
38
38
  out += "</p>"
39
39
 
40
40
  out += "<h4>Constraints:</h4>\n"
41
41
  for i, x in enumerate(policy.constraints):
42
42
  out += "<p>"
43
- out += "{}. {}\n".format(i+1, x)
43
+ out += "{}. {}\n".format(i + 1, x)
44
44
  out += "</p>"
45
45
 
46
46
  if policy.policy_options:
47
47
  out += "<h4>Policy Options:</h4>\n"
48
48
  for i, x in enumerate(policy.policy_options):
49
49
  out += "<details>"
50
- out += "<summary><b>{}. {}</b></summary>".format(i+1, x.name)
50
+ out += "<summary><b>{}. {}</b></summary>".format(i + 1, x.name)
51
51
  out += "<p>"
52
52
  out += x.description
53
53
  out += "</p>"
@@ -5,11 +5,13 @@ from typing import List, TypedDict
5
5
  def write_out_space(space: TypedDict) -> str:
6
6
  out = ""
7
7
  out += "<h3>"
8
- out += space.__name__
8
+ out += space.name
9
9
  out += "</h3>"
10
10
 
11
- d = space.__annotations__
12
- d = ",<br/>".join(["{}: {}".format(a, b.__name__) for a,b in zip(d.keys(), d.values())])
11
+ d = space.schema
12
+ d = ",<br/>".join(
13
+ ["{}: {}".format(a, b.__name__) for a, b in zip(d.keys(), d.values())]
14
+ )
13
15
  d = "{" + d + "}"
14
16
 
15
17
  out += "<p>"
@@ -24,4 +26,4 @@ def write_out_spaces(ms: MathSpec, spaces: List[str]) -> str:
24
26
  for name in spaces:
25
27
  out += write_out_space(ms.spaces[name])
26
28
 
27
- return out
29
+ return out
@@ -9,14 +9,18 @@ def write_state_variable_table(target_state):
9
9
  </tr>"""
10
10
 
11
11
  for var in target_state.variables:
12
- table_vars = [var.name, var.description,
13
- var.type.__name__, var.symbol, var.domain]
12
+ table_vars = [
13
+ var.name,
14
+ var.description,
15
+ var.type.__name__,
16
+ var.symbol,
17
+ var.domain,
18
+ ]
14
19
  table += "<tr>"
15
20
  for tv in table_vars:
16
21
  table += "<td>"
17
22
  if tv:
18
- table += "{}".format(tv).replace("<",
19
- "&lt").replace(">", "&gt")
23
+ table += "{}".format(tv).replace("<", "&lt").replace(">", "&gt")
20
24
  table += "</td>"
21
25
 
22
26
  table += "</tr>"
@@ -31,4 +35,4 @@ def write_local_state_variable_tables(states):
31
35
  for state in states:
32
36
  out += "<h4>{}</h4>".format(state.name)
33
37
  out += write_state_variable_table(state)
34
- return out
38
+ return out
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: math_spec_mapping
3
- Version: 0.1.2
3
+ Version: 0.1.3
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
@@ -11,6 +11,7 @@ src/Classes/MathSpec.py
11
11
  src/Classes/Mechanism.py
12
12
  src/Classes/Parameter.py
13
13
  src/Classes/Policy.py
14
+ src/Classes/Space.py
14
15
  src/Classes/State.py
15
16
  src/Classes/StateUpdateTransmissionChannel.py
16
17
  src/Classes/StatefulMetric.py
@@ -1,13 +0,0 @@
1
- from typing import Dict
2
-
3
-
4
- def load_spaces(ms: Dict, json: Dict) -> None:
5
- """Function to load spaces into the new dictionary
6
-
7
- Args:
8
- ms (Dict): MathSpec dictionary
9
- json (Dict): JSON version of MathSpec to load
10
- """
11
-
12
- # Placeholder for now
13
- ms["Spaces"] = json["Spaces"]
@@ -30,6 +30,7 @@ def load_from_json(json: Dict) -> MathSpec:
30
30
  ms = {}
31
31
 
32
32
  # Do loading one by one to transfer the json
33
+ load_spaces(ms, json)
33
34
  load_states(ms, json)
34
35
  load_entities(ms, json)
35
36
  load_boundary_actions(ms, json)
@@ -37,7 +38,6 @@ def load_from_json(json: Dict) -> MathSpec:
37
38
  load_mechanisms(ms, json)
38
39
  load_parameters(ms, json)
39
40
  load_policies(ms, json)
40
- load_spaces(ms, json)
41
41
  load_stateful_metrics(ms, json)
42
42
  load_action_transmission_channels(ms, json)
43
43
  load_state_update_transmission_channels(ms, json)