math-spec-mapping 0.3.9__py3-none-any.whl → 0.3.10__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,7 +4,6 @@ from .Block import Block
4
4
 
5
5
  class BoundaryAction(Block):
6
6
  def __init__(self, data: Dict):
7
- data["domain"] = tuple()
8
7
  super().__init__(data)
9
8
  self.boundary_action_options = data["boundary_action_options"]
10
9
  self.block_type = "Boundary Action"
@@ -4,7 +4,6 @@ from .Block import Block
4
4
 
5
5
  class ControlAction(Block):
6
6
  def __init__(self, data: Dict):
7
- data["domain"] = tuple()
8
7
  super().__init__(data)
9
8
  self.control_action_options = data["control_action_options"]
10
9
  self.block_type = "Control Action"
@@ -775,6 +775,7 @@ class MathSpecImplementation:
775
775
  self.policies = self.load_policies()
776
776
  self.mechanisms = self.load_mechanisms()
777
777
  self.stateful_metrics = self.load_stateful_metrics()
778
+ self.metrics = self.load_metrics()
778
779
  self.load_wiring()
779
780
  self.load_components()
780
781
 
@@ -951,6 +952,22 @@ class MathSpecImplementation:
951
952
 
952
953
  return stateful_metrics
953
954
 
955
+ def load_metrics(self):
956
+ metrics = {}
957
+
958
+ for m in self.ms.metrics:
959
+ m = self.ms.metrics[m]
960
+ if "python" not in m.implementations:
961
+ print(
962
+ "No python implementation for {}. To fix this, go to Implementations/Python/Metrics and add {}".format(
963
+ m.name, m.name
964
+ )
965
+ )
966
+ else:
967
+ metrics[m.name] = m.implementations["python"]
968
+
969
+ return metrics
970
+
954
971
  def load_wiring(
955
972
  self,
956
973
  ):
@@ -1026,6 +1043,7 @@ class MathSpecImplementation:
1026
1043
  state = deepcopy(state)
1027
1044
  params = deepcopy(params)
1028
1045
  state["Stateful Metrics"] = self.stateful_metrics
1046
+ state["Metrics"] = self.metrics
1029
1047
  if state_preperation_functions:
1030
1048
  for f in state_preperation_functions:
1031
1049
  state = f(state)
@@ -15,3 +15,4 @@ class Metric:
15
15
  else:
16
16
  self.label = self.name
17
17
  self.metadata = data["metadata"]
18
+ self.implementations = data["implementations"]
@@ -59,6 +59,7 @@ def convert_boundary_action(data: Dict, ms: Dict) -> BoundaryAction:
59
59
  data["called_by"] = [ms["Entities"][x] for x in data["called_by"]]
60
60
 
61
61
  data["codomain"] = tuple(ms["Spaces"][x] for x in data["codomain"])
62
+ data["domain"] = (ms["Spaces"]["Empty Space"],)
62
63
 
63
64
  # Build the boundary action object
64
65
  return BoundaryAction(data)
@@ -49,6 +49,7 @@ def convert_control_action(data: Dict, ms: Dict) -> ControlAction:
49
49
  data["control_action_options"] = new_cao
50
50
 
51
51
  data["codomain"] = tuple(ms["Spaces"][x] for x in data["codomain"])
52
+ data["domain"] = (ms["Spaces"]["Empty Space"],)
52
53
 
53
54
  # Build the control action object
54
55
  return ControlAction(data)
@@ -50,6 +50,14 @@ def convert_metric(ms, data: Dict, stateful_metrics_map) -> Metric:
50
50
  for x in data["metrics_used"]
51
51
  )
52
52
 
53
+ data["implementations"] = {}
54
+ if "python" in ms["Implementations"]:
55
+ if "metrics" in ms["Implementations"]["python"]:
56
+ if data["name"] in ms["Implementations"]["python"]["metrics"]:
57
+ data["implementations"]["python"] = ms["Implementations"]["python"][
58
+ "metrics"
59
+ ][data["name"]]
60
+
53
61
  # Build the metric object
54
62
  return Metric(data)
55
63
 
@@ -91,7 +99,9 @@ def load_metrics(ms: Dict, json: Dict, stateful_metrics_map) -> None:
91
99
  for z in y["metrics_used"]:
92
100
  assert (
93
101
  z in ms["Metrics"] or z in names or z in stateful_metrics_map
94
- ), "{} is not defined in the spec".format(z)
102
+ ), "{} is not defined in the spec, but it is referenced in {}".format(
103
+ z, y["name"]
104
+ )
95
105
  assert len(metrics) == 0, "There are circular references"
96
106
 
97
107
  # Load the metrics into the policies
@@ -13,8 +13,10 @@ def convert_space(ms, data: Dict) -> Space:
13
13
  data = data.copy()
14
14
 
15
15
  for x in data["schema"]:
16
- assert data["schema"][x] in ms["Types"], "Type {} not in ms".format(
17
- data["schema"][x]
16
+ assert (
17
+ data["schema"][x] in ms["Types"]
18
+ ), "Type {} not in ms for space {} at attribute {}".format(
19
+ data["schema"][x], data["name"], x
18
20
  )
19
21
  data["schema"][x] = ms["Types"][data["schema"][x]]
20
22
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: math-spec-mapping
3
- Version: 0.3.9
3
+ Version: 0.3.10
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,12 +3,12 @@ math_spec_mapping/schema.py,sha256=6mrRqzEnTTSXjb19xJ63MBp0KjKH0s7i6TfT4MkAY9k,2
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
5
  math_spec_mapping/Classes/Block.py,sha256=cGtIhNgRfoDZ0O3SxeXcNzNlHcdXIB89sT2uaZct8LY,17667
6
- math_spec_mapping/Classes/BoundaryAction.py,sha256=KuZqtvZwSHWDP7gFQXGnG-r3EuYJU_oU9wMCuqvRkzk,593
7
- math_spec_mapping/Classes/ControlAction.py,sha256=ysqpgANwdizVdwqtgZmnxXMpCqrzmVEF_6YT0M3l4Ho,526
6
+ math_spec_mapping/Classes/BoundaryAction.py,sha256=_rFvEZ4LNxmlM59js4SuQ9n5CgVmITw4YWKs0-q0r-4,560
7
+ math_spec_mapping/Classes/ControlAction.py,sha256=4AzMSA8fbnUf-fGlvMJXHJFbz32G1h1QVWf2yzrXrLA,493
8
8
  math_spec_mapping/Classes/Entity.py,sha256=fA0-b128_OHHxfCg4pzqyQV083EYev1HlVpy86S5igg,1226
9
- math_spec_mapping/Classes/MathSpec.py,sha256=6cBpp9OHmfU-XTqPI4Qjnj91cXRxfGtcAQnczOKxt-4,39892
9
+ math_spec_mapping/Classes/MathSpec.py,sha256=8gU1EgVuiHjI7olVXJiPgFQlDUF2sEcjmGZ2cQv86k0,40475
10
10
  math_spec_mapping/Classes/Mechanism.py,sha256=2sLm3wYBIeTQaMBcsJ9btqIWsbS895Ra8NY6Y9_G_Dg,379
11
- math_spec_mapping/Classes/Metric.py,sha256=AhPgYppOP6q49xvR8S9STxQsXUKJlTWx7wI1LfZEtww,581
11
+ math_spec_mapping/Classes/Metric.py,sha256=iQhH4g8Z60QlM22nPX9ytGmidOsZSiSs0KjqwmsScwU,636
12
12
  math_spec_mapping/Classes/Parameter.py,sha256=ZuJ_w0sChvRElJ4sOnXZ2EV4Ell2xXFulKLjVOpgz2E,1237
13
13
  math_spec_mapping/Classes/Policy.py,sha256=fzV85tB3QScjiYGfhw_dyQt9L1BYYfTyTIQQcxeT8ac,530
14
14
  math_spec_mapping/Classes/Space.py,sha256=QsahxoUfRsDWQLBL683KnGx72MAmRxv7CDE7TMgCG-E,472
@@ -22,18 +22,18 @@ math_spec_mapping/Convenience/documentation.py,sha256=1ziWVJznbCUxeAAt03nAdEYtMl
22
22
  math_spec_mapping/Convenience/starter.py,sha256=9dBKU3EHscut2wA6Nx1XUmehrFIdr4dCjP9V1BbTF6s,12567
23
23
  math_spec_mapping/Load/__init__.py,sha256=_ga5nHi7U5rY5lCF36_XI9Qmybq4P8R4m5I5mmjLBk8,33
24
24
  math_spec_mapping/Load/action_transmission_channel.py,sha256=9Wer7g2s5SSOcUYuZ0PqSKUVVnW3EvGQJZNXJTwW__0,2561
25
- math_spec_mapping/Load/boundary_actions.py,sha256=q-jxhu8FaKNjdOdexlK6f22GDgraGa1jnL5kEzQ7mJY,2625
26
- math_spec_mapping/Load/control_actions.py,sha256=4E57s730W4tX5SaKXKaAvet37r8Bwt-g8Kk6EanF4TU,2042
25
+ math_spec_mapping/Load/boundary_actions.py,sha256=ms3Oh09Dgur9sZrxOE5FrzNO4zN41cWPNOW563R0A5U,2677
26
+ math_spec_mapping/Load/control_actions.py,sha256=W7kKLcA0UQ40m1ZExmvu0ujdxvJ8wH-uQ9PG8hbaYCo,2094
27
27
  math_spec_mapping/Load/displays.py,sha256=uQvs0Jhp8-9SXGex8SG3ibxHJu7ahAV3xLeBFbT8QEE,480
28
28
  math_spec_mapping/Load/entities.py,sha256=Ds7VQY_govWEn1vSHYVrLa8IadSNyOQzaCK18JPYPKk,1289
29
29
  math_spec_mapping/Load/general.py,sha256=2q6aGKxXhebiHHTZhtACvM4nWIkTben0o5rXuvfv2Vw,4463
30
30
  math_spec_mapping/Load/implementations.py,sha256=SGKZ_YXeNpJUTnw5fajQTXji7S2bNQo8sh-7YcIO6pk,395
31
31
  math_spec_mapping/Load/load.py,sha256=CLprDhJpbwm9RAzKM2Ghwr8eqBu0a-wvGDOCMmc01YE,2484
32
32
  math_spec_mapping/Load/mechanism.py,sha256=JBy-QpB4W0Z2OcNiakONjD4_RtEgxlFKtLXfDqfhR-0,2037
33
- math_spec_mapping/Load/metrics.py,sha256=EyCFEgHpyffBPKaqISdIeTyqUtPtu2xoS0gZjh-6i3U,3434
33
+ math_spec_mapping/Load/metrics.py,sha256=0XL-E7PUZg5PX_ZensoDpT2Z2xq893JncBEYbPzxeGo,3866
34
34
  math_spec_mapping/Load/parameters.py,sha256=W4utm7to3s2fo4z3XgLH0TM1agaIad1qfM2I-lLMua4,1393
35
35
  math_spec_mapping/Load/policy.py,sha256=HvlhGHGJTweVs7DOI2HSL_2_diECr8ukDUmzoFLQELo,2444
36
- math_spec_mapping/Load/spaces.py,sha256=7zgGA57Te7T4hfuCCDElffiidWgn1lKm5E14e1yjt8M,1116
36
+ math_spec_mapping/Load/spaces.py,sha256=5nJto38BVMED5KuMXOqavYj8gcSTKiNSTdMOOp5ThTA,1186
37
37
  math_spec_mapping/Load/state_update_transmission_channels.py,sha256=FJWp5n4HdtHAfof5BUQ6BnRakljatL2h8dWCapaVSc0,2238
38
38
  math_spec_mapping/Load/stateful_metrics.py,sha256=3Lq1ZGMaDd5OcGeqR2p5c_znkYw7ETTNPFjUVdZAHKk,2384
39
39
  math_spec_mapping/Load/states.py,sha256=3YurI7eTNkN6nrXRFVrc58wH0VfM22XOuWE07HVpR7Y,1365
@@ -53,8 +53,8 @@ math_spec_mapping/Reports/spaces.py,sha256=-76hR5wQBv4lsG000ypBJ-OprjsNjI-rNRMYd
53
53
  math_spec_mapping/Reports/state.py,sha256=EPiHz3cDCEPHnVjuFruVKaGJ2SclUfGUFvvOukiHPNg,3110
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.9.dist-info/LICENSE,sha256=ObyEzSw8kgCaFbEfpu1zP4TrcAKLA0xhqHMZZfyh7N0,1069
57
- math_spec_mapping-0.3.9.dist-info/METADATA,sha256=LHloXu-KQrrxTtV_ds9ZnHzTRiQ2w-08YvPSrOKP4nY,6500
58
- math_spec_mapping-0.3.9.dist-info/WHEEL,sha256=Wyh-_nZ0DJYolHNn1_hMa4lM7uDedD_RGVwbmTjyItk,91
59
- math_spec_mapping-0.3.9.dist-info/top_level.txt,sha256=AImhn9wgazkdV0a9vfiphtQR8uGe2nq-ZIOp-6yUk9o,18
60
- math_spec_mapping-0.3.9.dist-info/RECORD,,
56
+ math_spec_mapping-0.3.10.dist-info/LICENSE,sha256=ObyEzSw8kgCaFbEfpu1zP4TrcAKLA0xhqHMZZfyh7N0,1069
57
+ math_spec_mapping-0.3.10.dist-info/METADATA,sha256=GeiDgMZu2pfRgBwMMI1hG4dioScjJ0C3qH8AhN9Ewm4,6501
58
+ math_spec_mapping-0.3.10.dist-info/WHEEL,sha256=HiCZjzuy6Dw0hdX5R3LCFPDmFS4BWl8H-8W39XfmgX4,91
59
+ math_spec_mapping-0.3.10.dist-info/top_level.txt,sha256=AImhn9wgazkdV0a9vfiphtQR8uGe2nq-ZIOp-6yUk9o,18
60
+ math_spec_mapping-0.3.10.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (71.1.0)
2
+ Generator: setuptools (72.2.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5