math-spec-mapping 0.1.1__tar.gz → 0.1.3__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {math_spec_mapping-0.1.1/src/math_spec_mapping.egg-info → math_spec_mapping-0.1.3}/PKG-INFO +2 -2
- {math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3}/README.md +1 -1
- {math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3}/pyproject.toml +1 -1
- math_spec_mapping-0.1.1/src/Classes/Mechanism.py → math_spec_mapping-0.1.3/src/Classes/Block.py +3 -4
- math_spec_mapping-0.1.3/src/Classes/BoundaryAction.py +16 -0
- math_spec_mapping-0.1.3/src/Classes/ControlAction.py +16 -0
- {math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3}/src/Classes/MathSpec.py +13 -0
- math_spec_mapping-0.1.3/src/Classes/Mechanism.py +10 -0
- math_spec_mapping-0.1.3/src/Classes/Policy.py +15 -0
- math_spec_mapping-0.1.3/src/Classes/Space.py +7 -0
- {math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3}/src/Classes/__init__.py +2 -1
- {math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3}/src/Load/action_transmission_channel.py +7 -5
- {math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3}/src/Load/boundary_actions.py +7 -3
- {math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3}/src/Load/control_actions.py +4 -1
- {math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3}/src/Load/general.py +2 -0
- {math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3}/src/Load/mechanism.py +4 -2
- {math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3}/src/Load/policy.py +5 -2
- math_spec_mapping-0.1.3/src/Load/spaces.py +29 -0
- {math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3}/src/Load/state_update_transmission_channels.py +11 -7
- {math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3}/src/Reports/html.py +2 -2
- {math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3}/src/Reports/mechanisms.py +4 -4
- {math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3}/src/Reports/node_map.py +12 -18
- {math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3}/src/Reports/policies.py +6 -6
- {math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3}/src/Reports/spaces.py +6 -4
- {math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3}/src/Reports/state.py +9 -5
- {math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3/src/math_spec_mapping.egg-info}/PKG-INFO +2 -2
- {math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3}/src/math_spec_mapping.egg-info/SOURCES.txt +2 -0
- math_spec_mapping-0.1.1/src/Classes/BoundaryAction.py +0 -26
- math_spec_mapping-0.1.1/src/Classes/ControlAction.py +0 -23
- math_spec_mapping-0.1.1/src/Classes/Policy.py +0 -27
- math_spec_mapping-0.1.1/src/Load/spaces.py +0 -13
- {math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3}/LICENSE +0 -0
- {math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3}/setup.cfg +0 -0
- {math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3}/src/Classes/ActionTransmissionChannel.py +0 -0
- {math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3}/src/Classes/Entity.py +0 -0
- {math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3}/src/Classes/Parameter.py +0 -0
- {math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3}/src/Classes/State.py +0 -0
- {math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3}/src/Classes/StateUpdateTransmissionChannel.py +0 -0
- {math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3}/src/Classes/StatefulMetric.py +0 -0
- {math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3}/src/Convenience/__init__.py +0 -0
- {math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3}/src/Convenience/starter.py +0 -0
- {math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3}/src/Load/__init__.py +0 -0
- {math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3}/src/Load/entities.py +0 -0
- {math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3}/src/Load/load.py +1 -1
- {math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3}/src/Load/parameters.py +0 -0
- {math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3}/src/Load/stateful_metrics.py +0 -0
- {math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3}/src/Load/states.py +0 -0
- {math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3}/src/Reports/__init__.py +0 -0
- {math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3}/src/Reports/boundary_actions.py +0 -0
- {math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3}/src/Reports/control_actions.py +0 -0
- {math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3}/src/Reports/general.py +0 -0
- {math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3}/src/Reports/parameters.py +0 -0
- {math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3}/src/Reports/tables.py +0 -0
- {math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3}/src/__init__.py +0 -0
- {math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3}/src/math_spec_mapping.egg-info/dependency_links.txt +0 -0
- {math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3}/src/math_spec_mapping.egg-info/requires.txt +0 -0
- {math_spec_mapping-0.1.1 → 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.
|
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
|
@@ -36,7 +36,7 @@ As well, there are times when you want a fully zoomed out view, and other times
|
|
36
36
|
|
37
37
|
|
38
38
|
```mermaid
|
39
|
-
graph
|
39
|
+
graph TD
|
40
40
|
A[JSON Object \n\n Each spec has a repo for tracking changes \n Must conform to the json specification \n Defines all aspects of the spec including blocks, spaces and actions] -->B[MSML Object \n\n JSON file and parsed, with validations and mappings along the way \n Can show different views on the fly]
|
41
41
|
B --> C[Report Outputs \n\n Automatically build reports for the full spec or subviews \n Example: all blocks with an effect on variable XYZ]
|
42
42
|
|
@@ -21,7 +21,7 @@ As well, there are times when you want a fully zoomed out view, and other times
|
|
21
21
|
|
22
22
|
|
23
23
|
```mermaid
|
24
|
-
graph
|
24
|
+
graph TD
|
25
25
|
A[JSON Object \n\n Each spec has a repo for tracking changes \n Must conform to the json specification \n Defines all aspects of the spec including blocks, spaces and actions] -->B[MSML Object \n\n JSON file and parsed, with validations and mappings along the way \n Can show different views on the fly]
|
26
26
|
B --> C[Report Outputs \n\n Automatically build reports for the full spec or subviews \n Example: all blocks with an effect on variable XYZ]
|
27
27
|
|
math_spec_mapping-0.1.1/src/Classes/Mechanism.py → math_spec_mapping-0.1.3/src/Classes/Block.py
RENAMED
@@ -1,18 +1,17 @@
|
|
1
1
|
from typing import Dict
|
2
2
|
|
3
3
|
|
4
|
-
class
|
5
|
-
|
4
|
+
class Block:
|
6
5
|
def __init__(self, data: Dict):
|
7
6
|
self.name = data["name"]
|
8
7
|
self.description = data["description"]
|
9
8
|
self.constraints = data["constraints"]
|
10
|
-
self.logic = data["logic"]
|
11
9
|
self.domain = data["domain"]
|
10
|
+
self.codomain = data["codomain"]
|
12
11
|
self.parameters_used = data["parameters_used"]
|
13
12
|
if "label" in data:
|
14
13
|
self.label = data["label"]
|
15
14
|
else:
|
16
15
|
self.label = self.name
|
17
16
|
self.called_by = []
|
18
|
-
self.
|
17
|
+
self.calls = []
|
@@ -0,0 +1,16 @@
|
|
1
|
+
from typing import Dict
|
2
|
+
from .Block import Block
|
3
|
+
|
4
|
+
|
5
|
+
class BoundaryAction(Block):
|
6
|
+
def __init__(self, data: Dict):
|
7
|
+
data["domain"] = None
|
8
|
+
super().__init__(data)
|
9
|
+
self.boundary_action_options = data["boundary_action_options"]
|
10
|
+
|
11
|
+
|
12
|
+
class BoundaryActionOption:
|
13
|
+
def __init__(self, data: Dict):
|
14
|
+
self.name = data["name"]
|
15
|
+
self.description = data["description"]
|
16
|
+
self.logic = data["logic"]
|
@@ -0,0 +1,16 @@
|
|
1
|
+
from typing import Dict
|
2
|
+
from .Block import Block
|
3
|
+
|
4
|
+
|
5
|
+
class ControlAction(Block):
|
6
|
+
def __init__(self, data: Dict):
|
7
|
+
data["domain"] = None
|
8
|
+
super().__init__(data)
|
9
|
+
self.control_action_options = data["control_action_options"]
|
10
|
+
|
11
|
+
|
12
|
+
class ControlActionOption:
|
13
|
+
def __init__(self, data: Dict):
|
14
|
+
self.name = data["name"]
|
15
|
+
self.description = data["description"]
|
16
|
+
self.logic = data["logic"]
|
@@ -28,6 +28,19 @@ class MathSpec:
|
|
28
28
|
self._check_parameters()
|
29
29
|
self._crawl_parameters()
|
30
30
|
self._crawl_parameters_exploded()
|
31
|
+
self._check_dictionary_names()
|
32
|
+
|
33
|
+
def _check_dictionary_names(self):
|
34
|
+
for key in self.boundary_actions:
|
35
|
+
assert key == self.boundary_actions[key].name
|
36
|
+
for key in self.control_actions:
|
37
|
+
assert key == self.control_actions[key].name
|
38
|
+
for key in self.entities:
|
39
|
+
assert key == self.entities[key].name
|
40
|
+
for key in self.mechanisms:
|
41
|
+
assert key == self.mechanisms[key].name
|
42
|
+
for key in self.policies:
|
43
|
+
assert key == self.policies[key].name
|
31
44
|
|
32
45
|
def _check_parameters(self):
|
33
46
|
for ba in self.boundary_actions.values():
|
@@ -0,0 +1,15 @@
|
|
1
|
+
from typing import Dict, List
|
2
|
+
from .Block import Block
|
3
|
+
|
4
|
+
|
5
|
+
class PolicyOption:
|
6
|
+
def __init__(self, data: Dict):
|
7
|
+
self.name = data["name"]
|
8
|
+
self.description = data["description"]
|
9
|
+
self.logic = data["logic"]
|
10
|
+
|
11
|
+
|
12
|
+
class Policy(Block):
|
13
|
+
def __init__(self, data: Dict):
|
14
|
+
super().__init__(data)
|
15
|
+
self.policy_options: List[PolicyOption] = data["policy_options"]
|
@@ -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(
|
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
|
-
|
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
|
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
|
+
)
|
@@ -87,6 +87,7 @@ def check_json_keys(json: Dict, check_set_key: str) -> None:
|
|
87
87
|
"codomain",
|
88
88
|
"parameters_used",
|
89
89
|
],
|
90
|
+
"Control Action Option": ["name", "description", "logic"],
|
90
91
|
"Boundary Action Option": ["name", "description", "logic"],
|
91
92
|
"Parameter Set": ["name", "notes", "parameters"],
|
92
93
|
"Parameter": [
|
@@ -97,6 +98,7 @@ def check_json_keys(json: Dict, check_set_key: str) -> None:
|
|
97
98
|
"domain",
|
98
99
|
"parameter_class",
|
99
100
|
],
|
101
|
+
"Space": ["name", "schema"],
|
100
102
|
}
|
101
103
|
|
102
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)
|
{math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3}/src/Load/state_update_transmission_channels.py
RENAMED
@@ -3,7 +3,9 @@ from ..Classes import StateUpdateTransmissionChannel
|
|
3
3
|
from .general import check_json_keys
|
4
4
|
|
5
5
|
|
6
|
-
def convert_state_update_transmission_channel(
|
6
|
+
def convert_state_update_transmission_channel(
|
7
|
+
data: Dict, ms: Dict
|
8
|
+
) -> StateUpdateTransmissionChannel:
|
7
9
|
"""Function to convert dictionary to state update transmission channel
|
8
10
|
|
9
11
|
Args:
|
@@ -19,24 +21,25 @@ def convert_state_update_transmission_channel(data: Dict, ms: Dict) -> StateUpda
|
|
19
21
|
|
20
22
|
# Assert the origin is in mechanisms then map
|
21
23
|
origin = data["origin"]
|
22
|
-
assert origin in ms["Mechanisms"]
|
24
|
+
assert origin in ms["Mechanisms"], "{} not found in mechanisms".format(origin)
|
23
25
|
data["origin"] = ms["Mechanisms"][origin]
|
24
26
|
|
25
27
|
# Assert entity is in entities then map
|
26
28
|
entity = data["entity"]
|
27
|
-
assert entity in ms["Entities"]
|
29
|
+
assert entity in ms["Entities"], "{} not found in entities".format(entity)
|
28
30
|
data["entity"] = ms["Entities"][entity]
|
29
31
|
|
30
32
|
# Assert variable is in entity state then map
|
31
33
|
entity = data["entity"]
|
32
34
|
variable = data["variable"]
|
33
35
|
|
34
|
-
assert variable in entity.state.variable_map
|
36
|
+
assert variable in entity.state.variable_map, "{} variable not in {} state".format(
|
37
|
+
variable, entity.name
|
38
|
+
)
|
35
39
|
data["variable"] = entity.state.variable_map[variable]
|
36
40
|
|
37
41
|
# Add in the updates logic
|
38
|
-
data["origin"].updates.append((data["entity"],
|
39
|
-
data["variable"]))
|
42
|
+
data["origin"].updates.append((data["entity"], data["variable"]))
|
40
43
|
data["entity"].state.updated_by.append(data["origin"])
|
41
44
|
data["entity"].add_impacted_by_mechanism(data["origin"])
|
42
45
|
data["variable"].updated_by.append(data["origin"])
|
@@ -59,4 +62,5 @@ def load_state_update_transmission_channels(ms: Dict, json: Dict) -> None:
|
|
59
62
|
ms["State Update Transmission Channels"] = []
|
60
63
|
for sutc in json["State Update Transmission Channels"]:
|
61
64
|
ms["State Update Transmission Channels"].append(
|
62
|
-
convert_state_update_transmission_channel(sutc, ms)
|
65
|
+
convert_state_update_transmission_channel(sutc, ms)
|
66
|
+
)
|
@@ -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.
|
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.
|
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.
|
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
|
-
|
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].
|
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].
|
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].
|
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.
|
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.
|
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.
|
8
|
+
out += space.name
|
9
9
|
out += "</h3>"
|
10
10
|
|
11
|
-
d = space.
|
12
|
-
d = ",<br/>".join(
|
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 = [
|
13
|
-
|
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
|
-
"<").replace(">", ">")
|
23
|
+
table += "{}".format(tv).replace("<", "<").replace(">", ">")
|
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.
|
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
|
@@ -36,7 +36,7 @@ As well, there are times when you want a fully zoomed out view, and other times
|
|
36
36
|
|
37
37
|
|
38
38
|
```mermaid
|
39
|
-
graph
|
39
|
+
graph TD
|
40
40
|
A[JSON Object \n\n Each spec has a repo for tracking changes \n Must conform to the json specification \n Defines all aspects of the spec including blocks, spaces and actions] -->B[MSML Object \n\n JSON file and parsed, with validations and mappings along the way \n Can show different views on the fly]
|
41
41
|
B --> C[Report Outputs \n\n Automatically build reports for the full spec or subviews \n Example: all blocks with an effect on variable XYZ]
|
42
42
|
|
{math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3}/src/math_spec_mapping.egg-info/SOURCES.txt
RENAMED
@@ -3,6 +3,7 @@ README.md
|
|
3
3
|
pyproject.toml
|
4
4
|
src/__init__.py
|
5
5
|
src/Classes/ActionTransmissionChannel.py
|
6
|
+
src/Classes/Block.py
|
6
7
|
src/Classes/BoundaryAction.py
|
7
8
|
src/Classes/ControlAction.py
|
8
9
|
src/Classes/Entity.py
|
@@ -10,6 +11,7 @@ src/Classes/MathSpec.py
|
|
10
11
|
src/Classes/Mechanism.py
|
11
12
|
src/Classes/Parameter.py
|
12
13
|
src/Classes/Policy.py
|
14
|
+
src/Classes/Space.py
|
13
15
|
src/Classes/State.py
|
14
16
|
src/Classes/StateUpdateTransmissionChannel.py
|
15
17
|
src/Classes/StatefulMetric.py
|
@@ -1,26 +0,0 @@
|
|
1
|
-
from typing import Dict
|
2
|
-
|
3
|
-
|
4
|
-
class BoundaryAction:
|
5
|
-
|
6
|
-
def __init__(self, data: Dict):
|
7
|
-
self.name = data['name']
|
8
|
-
self.description = data["description"]
|
9
|
-
self.constraints = data["constraints"]
|
10
|
-
self.boundary_action_options = data["boundary_action_options"]
|
11
|
-
self.called_by = data["called_by"]
|
12
|
-
self.codomain = data["codomain"]
|
13
|
-
self.parameters_used = data["parameters_used"]
|
14
|
-
if "label" in data:
|
15
|
-
self.label = data["label"]
|
16
|
-
else:
|
17
|
-
self.label = self.name
|
18
|
-
self.calls = []
|
19
|
-
|
20
|
-
|
21
|
-
class BoundaryActionOption:
|
22
|
-
|
23
|
-
def __init__(self, data: Dict):
|
24
|
-
self.name = data["name"]
|
25
|
-
self.description = data["description"]
|
26
|
-
self.logic = data["logic"]
|
@@ -1,23 +0,0 @@
|
|
1
|
-
from typing import Dict
|
2
|
-
|
3
|
-
|
4
|
-
class ControlAction:
|
5
|
-
|
6
|
-
def __init__(self, data: Dict):
|
7
|
-
self.name = data['name']
|
8
|
-
self.description = data["description"]
|
9
|
-
self.constraints = data["constraints"]
|
10
|
-
self.control_action_options = data["control_action_options"]
|
11
|
-
self.codomain = data["codomain"]
|
12
|
-
self.parameters_used = data["parameters_used"]
|
13
|
-
if "label" in data:
|
14
|
-
self.label = data["label"]
|
15
|
-
else:
|
16
|
-
self.label = self.name
|
17
|
-
self.calls = []
|
18
|
-
|
19
|
-
|
20
|
-
class ControlActionOption:
|
21
|
-
|
22
|
-
def __init__(self, data: Dict):
|
23
|
-
pass
|
@@ -1,27 +0,0 @@
|
|
1
|
-
from typing import Dict
|
2
|
-
|
3
|
-
|
4
|
-
class Policy:
|
5
|
-
|
6
|
-
def __init__(self, data: Dict):
|
7
|
-
self.name = data["name"]
|
8
|
-
self.description = data["description"]
|
9
|
-
self.constraints = data["constraints"]
|
10
|
-
self.policy_options = data["policy_options"]
|
11
|
-
self.domain = data["domain"]
|
12
|
-
self.codomain = data["codomain"]
|
13
|
-
self.parameters_used = data["parameters_used"]
|
14
|
-
if "label" in data:
|
15
|
-
self.label = data["label"]
|
16
|
-
else:
|
17
|
-
self.label = self.name
|
18
|
-
self.called_by = []
|
19
|
-
self.calls = []
|
20
|
-
|
21
|
-
|
22
|
-
class PolicyOption:
|
23
|
-
|
24
|
-
def __init__(self, data: Dict):
|
25
|
-
self.name = data["name"]
|
26
|
-
self.description = data["description"]
|
27
|
-
self.logic = data["logic"]
|
@@ -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"]
|
File without changes
|
File without changes
|
{math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3}/src/Classes/ActionTransmissionChannel.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3}/src/Classes/StateUpdateTransmissionChannel.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -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)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3}/src/math_spec_mapping.egg-info/requires.txt
RENAMED
File without changes
|
{math_spec_mapping-0.1.1 → math_spec_mapping-0.1.3}/src/math_spec_mapping.egg-info/top_level.txt
RENAMED
File without changes
|