math-spec-mapping 0.3.9.1__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.
@@ -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"]
@@ -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.1
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
@@ -6,9 +6,9 @@ math_spec_mapping/Classes/Block.py,sha256=cGtIhNgRfoDZ0O3SxeXcNzNlHcdXIB89sT2uaZ
6
6
  math_spec_mapping/Classes/BoundaryAction.py,sha256=_rFvEZ4LNxmlM59js4SuQ9n5CgVmITw4YWKs0-q0r-4,560
7
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
@@ -30,10 +30,10 @@ math_spec_mapping/Load/general.py,sha256=2q6aGKxXhebiHHTZhtACvM4nWIkTben0o5rXuvf
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.1.dist-info/LICENSE,sha256=ObyEzSw8kgCaFbEfpu1zP4TrcAKLA0xhqHMZZfyh7N0,1069
57
- math_spec_mapping-0.3.9.1.dist-info/METADATA,sha256=VV9OF55yc5n0xe5_JnFBq2hDAOQ0Eu1WMahCTjQqWRg,6502
58
- math_spec_mapping-0.3.9.1.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
59
- math_spec_mapping-0.3.9.1.dist-info/top_level.txt,sha256=AImhn9wgazkdV0a9vfiphtQR8uGe2nq-ZIOp-6yUk9o,18
60
- math_spec_mapping-0.3.9.1.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 (72.1.0)
2
+ Generator: setuptools (72.2.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5