math-spec-mapping 0.3.5__py3-none-any.whl → 0.3.6__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- math_spec_mapping/Classes/Block.py +5 -0
- math_spec_mapping/Classes/MathSpec.py +51 -4
- math_spec_mapping/Classes/StatefulMetric.py +1 -0
- math_spec_mapping/Load/stateful_metrics.py +9 -0
- math_spec_mapping/Reports/markdown.py +1 -1
- {math_spec_mapping-0.3.5.dist-info → math_spec_mapping-0.3.6.dist-info}/METADATA +1 -1
- {math_spec_mapping-0.3.5.dist-info → math_spec_mapping-0.3.6.dist-info}/RECORD +10 -10
- {math_spec_mapping-0.3.5.dist-info → math_spec_mapping-0.3.6.dist-info}/LICENSE +0 -0
- {math_spec_mapping-0.3.5.dist-info → math_spec_mapping-0.3.6.dist-info}/WHEEL +0 -0
- {math_spec_mapping-0.3.5.dist-info → math_spec_mapping-0.3.6.dist-info}/top_level.txt +0 -0
@@ -37,6 +37,7 @@ class Block:
|
|
37
37
|
)
|
38
38
|
]
|
39
39
|
)
|
40
|
+
self.domain_blocks2 = self.domain_blocks[:]
|
40
41
|
self.codomain_blocks = tuple(
|
41
42
|
[
|
42
43
|
self
|
@@ -191,6 +192,9 @@ class ParallelBlock(Block):
|
|
191
192
|
self.domain_blocks = tuple(
|
192
193
|
[i for x in self.components for i in x.domain_blocks]
|
193
194
|
)
|
195
|
+
self.domain_blocks2 = tuple(
|
196
|
+
[x for x in self.components for i in x.domain_blocks2]
|
197
|
+
)
|
194
198
|
self.codomain_blocks = tuple(
|
195
199
|
[i for x in self.components for i in x.codomain_blocks]
|
196
200
|
)
|
@@ -320,6 +324,7 @@ class StackBlock(Block):
|
|
320
324
|
)
|
321
325
|
|
322
326
|
self.domain_blocks = self.components[0].domain_blocks
|
327
|
+
self.domain_blocks2 = self.components[0].domain_blocks2
|
323
328
|
self.codomain_blocks = self.components[-1].codomain_blocks
|
324
329
|
self.domain_blocks_empty = self.components[0].domain_blocks_empty
|
325
330
|
self.codomain_blocks_empty = self.components[-1].codomain_blocks_empty
|
@@ -45,6 +45,7 @@ class MathSpec:
|
|
45
45
|
self._check_dictionary_names()
|
46
46
|
self._build_functional_parameters()
|
47
47
|
self._build_parameter_types()
|
48
|
+
self._crawl_spaces()
|
48
49
|
|
49
50
|
def _check_dictionary_names(self):
|
50
51
|
for key in self.boundary_actions:
|
@@ -406,6 +407,18 @@ class MathSpec:
|
|
406
407
|
self.behavioral_parameters_types = behavioral_parameters_types
|
407
408
|
self.functional_parameters_types = functional_parameters_types
|
408
409
|
|
410
|
+
def _crawl_spaces(self):
|
411
|
+
self._used_spaces = []
|
412
|
+
self._used_spaces.extend([x.codomain for x in self.control_actions.values()])
|
413
|
+
self._used_spaces.extend([x.codomain for x in self.boundary_actions.values()])
|
414
|
+
self._used_spaces.extend([x.domain for x in self.policies.values()])
|
415
|
+
self._used_spaces.extend([x.codomain for x in self.policies.values()])
|
416
|
+
self._used_spaces.extend([x.domain for x in self.mechanisms.values()])
|
417
|
+
|
418
|
+
self._used_spaces = list(set().union(*self._used_spaces))
|
419
|
+
us_names = [y.name for y in self._used_spaces]
|
420
|
+
self._unused_spaces = [self.spaces[x] for x in self.spaces if x not in us_names]
|
421
|
+
|
409
422
|
def metaprogramming_python_types(self, model_directory, overwrite=False):
|
410
423
|
path = model_directory + "/types.py"
|
411
424
|
if not overwrite:
|
@@ -683,6 +696,7 @@ class MathSpecImplementation:
|
|
683
696
|
self.boundary_actions = self.load_boundary_actions()
|
684
697
|
self.policies = self.load_policies()
|
685
698
|
self.mechanisms = self.load_mechanisms()
|
699
|
+
self.stateful_metrics = self.load_stateful_metrics()
|
686
700
|
self.load_wiring()
|
687
701
|
|
688
702
|
def load_control_actions(self):
|
@@ -761,6 +775,7 @@ class MathSpecImplementation:
|
|
761
775
|
return mechanisms
|
762
776
|
|
763
777
|
def load_single_wiring(self, wiring):
|
778
|
+
hold = wiring
|
764
779
|
components = [x.name for x in wiring.components]
|
765
780
|
if wiring.block_type == "Stack Block":
|
766
781
|
|
@@ -772,16 +787,25 @@ class MathSpecImplementation:
|
|
772
787
|
elif wiring.block_type == "Parallel Block":
|
773
788
|
|
774
789
|
spaces_mapping = {}
|
775
|
-
for x in wiring.components:
|
776
|
-
spaces_mapping[x.name] = []
|
777
790
|
|
778
|
-
for
|
791
|
+
for y in [x.name for x in wiring.domain_blocks2]:
|
792
|
+
spaces_mapping[y] = []
|
793
|
+
|
794
|
+
for i, x in enumerate([x.name for x in wiring.domain_blocks2]):
|
779
795
|
spaces_mapping[x].append(i)
|
780
796
|
|
781
797
|
def wiring(state, params, spaces):
|
782
798
|
codomain = []
|
783
799
|
for component in components:
|
784
|
-
|
800
|
+
if component in spaces_mapping:
|
801
|
+
spaces_i = [spaces[i] for i in spaces_mapping[component]]
|
802
|
+
else:
|
803
|
+
assert component in [
|
804
|
+
x.name for x in hold.domain_blocks_empty
|
805
|
+
], "{} not in domain_blocks_empty of wiring {}".format(
|
806
|
+
component, hold
|
807
|
+
)
|
808
|
+
spaces_i = []
|
785
809
|
spaces_i = self.blocks[component](state, params, spaces_i)
|
786
810
|
if spaces_i:
|
787
811
|
codomain.extend(spaces_i)
|
@@ -822,6 +846,22 @@ class MathSpecImplementation:
|
|
822
846
|
policies[p.name] = opt.implementations["python"]
|
823
847
|
return policies
|
824
848
|
|
849
|
+
def load_stateful_metrics(self):
|
850
|
+
stateful_metrics = {}
|
851
|
+
|
852
|
+
for sm in self.ms.stateful_metrics_map:
|
853
|
+
sm = self.ms.stateful_metrics_map[sm]
|
854
|
+
if "python" not in sm.implementations:
|
855
|
+
print(
|
856
|
+
"No python implementation for {}. To fix this, go to Implementations/Python/StatefulMetrics and add {}".format(
|
857
|
+
sm.name, sm.name
|
858
|
+
)
|
859
|
+
)
|
860
|
+
else:
|
861
|
+
stateful_metrics[sm.name] = sm.implementations["python"]
|
862
|
+
|
863
|
+
return stateful_metrics
|
864
|
+
|
825
865
|
def load_wiring(
|
826
866
|
self,
|
827
867
|
):
|
@@ -885,3 +925,10 @@ class MathSpecImplementation:
|
|
885
925
|
assert (
|
886
926
|
len(shouldnt_be_in_params) == 0
|
887
927
|
), "The following parameters are extra: {}".format(shouldnt_be_in_params)
|
928
|
+
|
929
|
+
def prepare_state_and_params(self, state, params):
|
930
|
+
self.validate_state_and_params(state, params)
|
931
|
+
state = deepcopy(state)
|
932
|
+
params = deepcopy(params)
|
933
|
+
state["Stateful Metrics"] = self.stateful_metrics
|
934
|
+
return state, params
|
@@ -39,6 +39,15 @@ def convert_stateful_metric(ms, data: Dict) -> StatefulMetricSet:
|
|
39
39
|
), "Variable '{}' not in variable map for stateful metrics variables used".format(
|
40
40
|
x[1]
|
41
41
|
)
|
42
|
+
|
43
|
+
var["implementations"] = {}
|
44
|
+
|
45
|
+
if "python" in ms["Implementations"]:
|
46
|
+
if "stateful_metrics" in ms["Implementations"]["python"]:
|
47
|
+
if var["name"] in ms["Implementations"]["python"]["stateful_metrics"]:
|
48
|
+
var["implementations"]["python"] = ms["Implementations"]["python"][
|
49
|
+
"stateful_metrics"
|
50
|
+
][var["name"]]
|
42
51
|
new_variables.append(StatefulMetric(var))
|
43
52
|
data["metrics"] = new_variables
|
44
53
|
|
@@ -538,7 +538,7 @@ def write_stateful_metrics_markdown_report(ms, path, metric, add_metadata=True):
|
|
538
538
|
out += "Domain: {}\n\n".format(metric.domain)
|
539
539
|
|
540
540
|
out += "## Parameters Used\n"
|
541
|
-
for i, x in enumerate(sorted(metric.parameters_used, key=lambda x: x
|
541
|
+
for i, x in enumerate(sorted(metric.parameters_used, key=lambda x: x)):
|
542
542
|
out += "{}. [[{}]]".format(i + 1, x)
|
543
543
|
out += "\n"
|
544
544
|
out += "\n"
|
@@ -2,11 +2,11 @@ math_spec_mapping/__init__.py,sha256=CzT9KycdX5nuiUzDFmLXVeAIr8v8UKGbXsEQF8vjl1c
|
|
2
2
|
math_spec_mapping/schema.py,sha256=6mrRqzEnTTSXjb19xJ63MBp0KjKH0s7i6TfT4MkAY9k,233
|
3
3
|
math_spec_mapping/schema.schema.json,sha256=hJP2TcV5WPFPmx4u_A5U1xtnpkE1LeYaTeYOXadTot0,30916
|
4
4
|
math_spec_mapping/Classes/ActionTransmissionChannel.py,sha256=zWMo5QsgPh5WGIWXl-xOrZNMXYJXmK6Vejw1dQvi0og,246
|
5
|
-
math_spec_mapping/Classes/Block.py,sha256=
|
5
|
+
math_spec_mapping/Classes/Block.py,sha256=cGtIhNgRfoDZ0O3SxeXcNzNlHcdXIB89sT2uaZct8LY,17667
|
6
6
|
math_spec_mapping/Classes/BoundaryAction.py,sha256=KuZqtvZwSHWDP7gFQXGnG-r3EuYJU_oU9wMCuqvRkzk,593
|
7
7
|
math_spec_mapping/Classes/ControlAction.py,sha256=ysqpgANwdizVdwqtgZmnxXMpCqrzmVEF_6YT0M3l4Ho,526
|
8
8
|
math_spec_mapping/Classes/Entity.py,sha256=fA0-b128_OHHxfCg4pzqyQV083EYev1HlVpy86S5igg,1226
|
9
|
-
math_spec_mapping/Classes/MathSpec.py,sha256=
|
9
|
+
math_spec_mapping/Classes/MathSpec.py,sha256=qH0F43SjytPDmxM1Hy3-8z9HzfRqNca-5X-6Vc5Sv8M,35294
|
10
10
|
math_spec_mapping/Classes/Mechanism.py,sha256=2sLm3wYBIeTQaMBcsJ9btqIWsbS895Ra8NY6Y9_G_Dg,379
|
11
11
|
math_spec_mapping/Classes/Metric.py,sha256=AhPgYppOP6q49xvR8S9STxQsXUKJlTWx7wI1LfZEtww,581
|
12
12
|
math_spec_mapping/Classes/Parameter.py,sha256=ZuJ_w0sChvRElJ4sOnXZ2EV4Ell2xXFulKLjVOpgz2E,1237
|
@@ -14,7 +14,7 @@ math_spec_mapping/Classes/Policy.py,sha256=fzV85tB3QScjiYGfhw_dyQt9L1BYYfTyTIQQc
|
|
14
14
|
math_spec_mapping/Classes/Space.py,sha256=QsahxoUfRsDWQLBL683KnGx72MAmRxv7CDE7TMgCG-E,472
|
15
15
|
math_spec_mapping/Classes/State.py,sha256=U40DoF2qlx_k9gvqQiP1S3C9ZLk3cW_-jmJn71TiCxg,1599
|
16
16
|
math_spec_mapping/Classes/StateUpdateTransmissionChannel.py,sha256=3hBLvD1lE64PkwqksBXAfFWv7foOZzGQLAFQWy42tOA,257
|
17
|
-
math_spec_mapping/Classes/StatefulMetric.py,sha256=
|
17
|
+
math_spec_mapping/Classes/StatefulMetric.py,sha256=plMFMAFEk1y2t4DR5lA2SRC9UrYArsx_W33l3mZSdgE,804
|
18
18
|
math_spec_mapping/Classes/Type.py,sha256=2KFY8d3cv1PzJJ7SSMHJf1zcfQ3ZbqxotK2KgTaLZdM,289
|
19
19
|
math_spec_mapping/Classes/__init__.py,sha256=0zxgOqns_9JybD74HKMVh6aw8ij8WVbfQ4Q_1uWzof0,761
|
20
20
|
math_spec_mapping/Convenience/__init__.py,sha256=z2W-E5Wg1CNEkDI5UqH3qIVBqp-3A1e63f3u9fA-N7w,112
|
@@ -35,7 +35,7 @@ math_spec_mapping/Load/parameters.py,sha256=W4utm7to3s2fo4z3XgLH0TM1agaIad1qfM2I
|
|
35
35
|
math_spec_mapping/Load/policy.py,sha256=HvlhGHGJTweVs7DOI2HSL_2_diECr8ukDUmzoFLQELo,2444
|
36
36
|
math_spec_mapping/Load/spaces.py,sha256=7zgGA57Te7T4hfuCCDElffiidWgn1lKm5E14e1yjt8M,1116
|
37
37
|
math_spec_mapping/Load/state_update_transmission_channels.py,sha256=FJWp5n4HdtHAfof5BUQ6BnRakljatL2h8dWCapaVSc0,2238
|
38
|
-
math_spec_mapping/Load/stateful_metrics.py,sha256=
|
38
|
+
math_spec_mapping/Load/stateful_metrics.py,sha256=pX2w3MvX2akFAOo6XWybkRE_X-v5BqchV2jTx0EekF0,2356
|
39
39
|
math_spec_mapping/Load/states.py,sha256=3YurI7eTNkN6nrXRFVrc58wH0VfM22XOuWE07HVpR7Y,1365
|
40
40
|
math_spec_mapping/Load/type.py,sha256=z6cBdBNjWed7cRyA0Bj7Jd5PmtemVVh07n3mWFj_5U4,4356
|
41
41
|
math_spec_mapping/Load/wiring.py,sha256=1dR94U5N1W_WI5rL6lYBltH25ZvApB2pIpq9r5Opkug,3083
|
@@ -44,7 +44,7 @@ math_spec_mapping/Reports/boundary_actions.py,sha256=45BPp4QjWdD-3E9ZWwqgj_nI2-Y
|
|
44
44
|
math_spec_mapping/Reports/control_actions.py,sha256=NksekZKIPFSIkubttFstKFthc5AU9B9PWRLSl9j1wWs,1216
|
45
45
|
math_spec_mapping/Reports/general.py,sha256=WOOn6Wlb8M4fsdN49FlKLwOka6vJPQ9aCUy88TL2ki0,1610
|
46
46
|
math_spec_mapping/Reports/html.py,sha256=uUXxMgGoL2yQelSg7CmJjIsU84SbZarqPg2d9x7Z13k,9220
|
47
|
-
math_spec_mapping/Reports/markdown.py,sha256=
|
47
|
+
math_spec_mapping/Reports/markdown.py,sha256=SdhgOMpMBnGKWDG0cimk-LI_UqjQDPy87IxTb-PrBQ0,22866
|
48
48
|
math_spec_mapping/Reports/mechanisms.py,sha256=d2Rxt3JBYvqAOAYUynl0buYVoXEHrO8EGq7GK6hK8NA,1322
|
49
49
|
math_spec_mapping/Reports/node_map.py,sha256=FdSMDQG16NX6n9sZcH-T5xwsvgjrV9OqBHc9J_VlNK0,3129
|
50
50
|
math_spec_mapping/Reports/parameters.py,sha256=yizNG4lNGrgrlzYYcHMGfXKDFlPw4PMDYshDqZ3YARs,535
|
@@ -53,8 +53,8 @@ math_spec_mapping/Reports/spaces.py,sha256=-76hR5wQBv4lsG000ypBJ-OprjsNjI-rNRMYd
|
|
53
53
|
math_spec_mapping/Reports/state.py,sha256=RkqfSonar74KVC8PpA9GgI2xaHX6BrkNdAuWMZlYQfI,2321
|
54
54
|
math_spec_mapping/Reports/tables.py,sha256=O0CNuqh3LMECq5uLjBOoxMUk5hUvkUK660FNnwWUxDY,1505
|
55
55
|
math_spec_mapping/Reports/wiring.py,sha256=u9SvKWy6T-WJUEgFI6-zgZanoOaTTs_2YwmEceDLsV8,1618
|
56
|
-
math_spec_mapping-0.3.
|
57
|
-
math_spec_mapping-0.3.
|
58
|
-
math_spec_mapping-0.3.
|
59
|
-
math_spec_mapping-0.3.
|
60
|
-
math_spec_mapping-0.3.
|
56
|
+
math_spec_mapping-0.3.6.dist-info/LICENSE,sha256=ObyEzSw8kgCaFbEfpu1zP4TrcAKLA0xhqHMZZfyh7N0,1069
|
57
|
+
math_spec_mapping-0.3.6.dist-info/METADATA,sha256=j1RD4vS3rk4E76cXbVAPsdYAKBjT2o6wpCNIQvKG1Ag,6012
|
58
|
+
math_spec_mapping-0.3.6.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
59
|
+
math_spec_mapping-0.3.6.dist-info/top_level.txt,sha256=AImhn9wgazkdV0a9vfiphtQR8uGe2nq-ZIOp-6yUk9o,18
|
60
|
+
math_spec_mapping-0.3.6.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|