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

Sign up to get free protection for your applications and to get access to all the features.
@@ -86,6 +86,8 @@ def remove_dummy_repo_components(path):
86
86
  contents = contents.replace("from .Dummy import dummy_mechanisms\n", "")
87
87
  contents = contents.replace("mechanism.extend(dummy_mechanisms)\n", "")
88
88
  contents = contents.replace("mechanism.extend(dummy_mechanisms)", "")
89
+ contents = contents.replace("mechanisms.extend(dummy_mechanisms)\n", "")
90
+ contents = contents.replace("mechanisms.extend(dummy_mechanisms)", "")
89
91
  with open(path2 + "/__init__.py", "w") as f:
90
92
  f.write(contents)
91
93
 
@@ -115,6 +117,15 @@ def remove_dummy_repo_components(path):
115
117
  "from .Dummy import dummy_boundary_action, dummy_boundary_action2\n",
116
118
  "",
117
119
  )
120
+ contents = contents.replace(
121
+ "from .Dummy import dummy_boundary_actions\n",
122
+ "",
123
+ )
124
+
125
+ contents = contents.replace(
126
+ "boundary_actions.extend(dummy_boundary_actions)",
127
+ "",
128
+ )
118
129
 
119
130
  contents = contents.replace("dummy_boundary_action2,\n", "")
120
131
  contents = contents.replace("dummy_boundary_action2,", "")
@@ -137,6 +148,13 @@ def remove_dummy_repo_components(path):
137
148
  contents = contents.replace(
138
149
  "from .Dummy import dummy_control_action\n", ""
139
150
  )
151
+ contents = contents.replace(
152
+ "from .Dummy import dummy_control_actions\n", ""
153
+ )
154
+ contents = contents.replace(
155
+ "control_actions.extend(dummy_control_actions)", ""
156
+ )
157
+
140
158
  contents = contents.replace("dummy_control_action,\n", "")
141
159
  contents = contents.replace("dummy_control_action,", "")
142
160
  contents = contents.replace("dummy_control_action", "")
@@ -214,6 +232,8 @@ def remove_dummy_repo_components(path):
214
232
  contents = contents.replace(
215
233
  "from .Dummy import DummyCompoundType, DummyType1, DummyType2\n", ""
216
234
  )
235
+ contents = contents.replace("from .Dummy import dummy_types\n", "")
236
+ contents = contents.replace("types.extend(dummy_types)", "")
217
237
  contents = contents.replace(
218
238
  """ DummyType1,
219
239
  DummyType2,
@@ -40,14 +40,14 @@ def convert_stateful_metric(ms, data: Dict) -> StatefulMetricSet:
40
40
  x[1]
41
41
  )
42
42
 
43
- var["implementations"] = {}
43
+ var["implementations"] = {}
44
+ if "python" in ms["Implementations"]:
45
+ if "stateful_metrics" in ms["Implementations"]["python"]:
46
+ if var["name"] in ms["Implementations"]["python"]["stateful_metrics"]:
47
+ var["implementations"]["python"] = ms["Implementations"]["python"][
48
+ "stateful_metrics"
49
+ ][var["name"]]
44
50
 
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"]]
51
51
  new_variables.append(StatefulMetric(var))
52
52
  data["metrics"] = new_variables
53
53
 
@@ -7,6 +7,7 @@ from .html import (
7
7
  write_basic_report_full,
8
8
  write_action_chain_reports,
9
9
  write_spec_tree,
10
+ write_parameter_table,
10
11
  write_entity_reports,
11
12
  write_overview,
12
13
  )
@@ -26,3 +27,8 @@ from .markdown import (
26
27
  write_stateful_metrics_markdown_report,
27
28
  write_all_markdown_reports,
28
29
  )
30
+ from .state import (
31
+ write_state_variable_table_markdown,
32
+ write_initial_state_variables_tables,
33
+ )
34
+ from .parameters import write_parameter_table_markdown
@@ -6,7 +6,7 @@ from .policies import write_out_policies
6
6
  from .mechanisms import write_out_mechanisms
7
7
  from .general import load_svg_graphviz, write_header
8
8
  from .node_map import create_action_chains_graph
9
- from .parameters import write_out_params
9
+ from .parameters import write_out_params, write_parameter_table_markdown
10
10
  from .state import write_local_state_variable_tables, write_global_state_variable_table
11
11
  from typing import List
12
12
  import os
@@ -267,3 +267,12 @@ def write_overview(ms: MathSpec, name: str, file_path: str, summary: str = None)
267
267
  out += write_spec_tree(ms, readme=True)
268
268
  with open(file_path, "w") as f:
269
269
  f.write(out)
270
+
271
+
272
+ def write_parameter_table(ms: MathSpec, path=None, linking=False) -> str:
273
+ out = write_parameter_table_markdown(ms, links=linking)
274
+ if path:
275
+ with open("{}/Paramter Table.md".format(path), "w") as f:
276
+ f.write(out)
277
+ else:
278
+ return out
@@ -13,3 +13,38 @@ def write_out_params(ms: MathSpec, params: List[str]) -> str:
13
13
  out += "<p>Parameter Class: {}</p>".format(param.parameter_class)
14
14
 
15
15
  return out
16
+
17
+
18
+ def write_parameter_table_markdown(ms, initial_values=None, links=False):
19
+ if initial_values:
20
+ table = """| Name | Description | Parameter Class | Symbol | Domain | Initial Value |
21
+ | --- | --- | --- | --- | --- | --- |
22
+ """
23
+ else:
24
+ table = """| Name | Description | Parameter Class | Symbol | Domain |
25
+ | --- | --- | --- | --- | --- |
26
+ """
27
+
28
+ for name in ms.parameters.parameter_map:
29
+ var = ms.parameters.parameter_map[name]
30
+ table_vars = [
31
+ var.name,
32
+ var.description,
33
+ var.parameter_class,
34
+ var.symbol,
35
+ var.domain,
36
+ ]
37
+ table += "|"
38
+ for i, tv in enumerate(table_vars):
39
+ if tv:
40
+ if links and i == 0:
41
+ table += "[[{}\|{}]]".format(tv, tv)
42
+ else:
43
+ table += "{}".format(tv)
44
+ table += "|"
45
+ if initial_values:
46
+ table += " {} |".format(initial_values[var.name])
47
+
48
+ table += "\n"
49
+
50
+ return table
@@ -33,8 +33,13 @@ def write_state_variable_table(target_state, links=False):
33
33
  return table
34
34
 
35
35
 
36
- def write_state_variable_table_markdown(target_state, links=False):
37
- table = """| Name | Description | Type | Symbol | Domain |
36
+ def write_state_variable_table_markdown(target_state, initial_values=None, links=False):
37
+ if initial_values:
38
+ table = """| Name | Description | Type | Symbol | Domain | Initial Value |
39
+ | --- | --- | --- | --- | --- | --- |
40
+ """
41
+ else:
42
+ table = """| Name | Description | Type | Symbol | Domain |
38
43
  | --- | --- | --- | --- | --- |
39
44
  """
40
45
 
@@ -56,12 +61,33 @@ def write_state_variable_table_markdown(target_state, links=False):
56
61
  else:
57
62
  table += "{}".format(tv)
58
63
  table += "|"
64
+ if initial_values:
65
+ table += " {} |".format(initial_values[var.name])
59
66
 
60
67
  table += "\n"
61
68
 
62
69
  return table
63
70
 
64
71
 
72
+ def write_initial_state_variables_tables(ms, initial_values, links=False):
73
+ out = "### Global State"
74
+ out += "\n\n"
75
+ out += write_state_variable_table_markdown(
76
+ ms.state["Global State"], initial_values=initial_values, links=links
77
+ )
78
+ out += "\n"
79
+ for x in ms.state:
80
+ if x == "Global State":
81
+ continue
82
+
83
+ out += "### {}".format(x)
84
+ out += "\n\n"
85
+ out += write_state_variable_table_markdown(ms.state[x], links=links)
86
+ out += "\n"
87
+
88
+ return out
89
+
90
+
65
91
  def write_global_state_variable_table(state):
66
92
  out = ""
67
93
  out += "<h3>Global State</h3>"
@@ -8,6 +8,7 @@ from .Reports import (
8
8
  write_basic_report_full,
9
9
  write_action_chain_reports,
10
10
  write_spec_tree,
11
+ write_parameter_table,
11
12
  create_parameter_impact_table,
12
13
  write_entity_reports,
13
14
  write_wiring_report,
@@ -24,6 +25,9 @@ from .Reports import (
24
25
  write_parameter_markdown_report,
25
26
  write_stateful_metrics_markdown_report,
26
27
  write_all_markdown_reports,
28
+ write_state_variable_table_markdown,
29
+ write_initial_state_variables_tables,
30
+ write_parameter_table_markdown,
27
31
  )
28
32
  from .schema import schema
29
33
  from .Convenience import remove_dummy_repo_components
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: math-spec-mapping
3
- Version: 0.3.8
3
+ Version: 0.3.9
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
@@ -1,4 +1,4 @@
1
- math_spec_mapping/__init__.py,sha256=CzT9KycdX5nuiUzDFmLXVeAIr8v8UKGbXsEQF8vjl1c,961
1
+ math_spec_mapping/__init__.py,sha256=5n9PbwtdXymhFpL0uUOmcpCBfCEgDp2T93QIASC73ts,1107
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
@@ -19,7 +19,7 @@ math_spec_mapping/Classes/Type.py,sha256=2KFY8d3cv1PzJJ7SSMHJf1zcfQ3ZbqxotK2KgTa
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
21
21
  math_spec_mapping/Convenience/documentation.py,sha256=1ziWVJznbCUxeAAt03nAdEYtMlXNo5TeedHfgs0vSBU,1625
22
- math_spec_mapping/Convenience/starter.py,sha256=vflOgTVRvM5OMBB7kHnoLR-sGeukKxOJNJmJzQm9Ick,11649
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
25
  math_spec_mapping/Load/boundary_actions.py,sha256=q-jxhu8FaKNjdOdexlK6f22GDgraGa1jnL5kEzQ7mJY,2625
@@ -35,26 +35,26 @@ 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=pX2w3MvX2akFAOo6XWybkRE_X-v5BqchV2jTx0EekF0,2356
38
+ math_spec_mapping/Load/stateful_metrics.py,sha256=3Lq1ZGMaDd5OcGeqR2p5c_znkYw7ETTNPFjUVdZAHKk,2384
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
42
- math_spec_mapping/Reports/__init__.py,sha256=W27I6S9Ro1hWeHmnxIokCA06awB__eYey7PvKD4Hc1s,933
42
+ math_spec_mapping/Reports/__init__.py,sha256=P3IuE1wiM1EO_yCSD73D4O0O6j7aVWmiwpKJM58ISEs,1121
43
43
  math_spec_mapping/Reports/boundary_actions.py,sha256=45BPp4QjWdD-3E9ZWwqgj_nI2-YdcI2ZZ19_Qv_K7Qk,1410
44
44
  math_spec_mapping/Reports/control_actions.py,sha256=NksekZKIPFSIkubttFstKFthc5AU9B9PWRLSl9j1wWs,1216
45
45
  math_spec_mapping/Reports/general.py,sha256=WOOn6Wlb8M4fsdN49FlKLwOka6vJPQ9aCUy88TL2ki0,1610
46
- math_spec_mapping/Reports/html.py,sha256=uUXxMgGoL2yQelSg7CmJjIsU84SbZarqPg2d9x7Z13k,9220
46
+ math_spec_mapping/Reports/html.py,sha256=zRo67S81pIRK_sttuFy8Y06qllen_K0lNS1qeHQo5ik,9521
47
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
- math_spec_mapping/Reports/parameters.py,sha256=yizNG4lNGrgrlzYYcHMGfXKDFlPw4PMDYshDqZ3YARs,535
50
+ math_spec_mapping/Reports/parameters.py,sha256=T73OKY3dWufeYEb6jSxGQH6GH4PSZLMmZcaV1m8qUn0,1553
51
51
  math_spec_mapping/Reports/policies.py,sha256=EuBzBsTM6QSS_GHFcAyhGgWvDDZwRuKe7Eos9nX13ho,1814
52
52
  math_spec_mapping/Reports/spaces.py,sha256=-76hR5wQBv4lsG000ypBJ-OprjsNjI-rNRMYdtsYnjQ,579
53
- math_spec_mapping/Reports/state.py,sha256=RkqfSonar74KVC8PpA9GgI2xaHX6BrkNdAuWMZlYQfI,2321
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.8.dist-info/LICENSE,sha256=ObyEzSw8kgCaFbEfpu1zP4TrcAKLA0xhqHMZZfyh7N0,1069
57
- math_spec_mapping-0.3.8.dist-info/METADATA,sha256=Rcdfu5GQQlfA6GnvqZopFBd2zJGe2JpHKoWUXVf3yoY,6500
58
- math_spec_mapping-0.3.8.dist-info/WHEEL,sha256=y4mX-SOX4fYIkonsAGA5N0Oy-8_gI4FXw5HNI1xqvWg,91
59
- math_spec_mapping-0.3.8.dist-info/top_level.txt,sha256=AImhn9wgazkdV0a9vfiphtQR8uGe2nq-ZIOp-6yUk9o,18
60
- math_spec_mapping-0.3.8.dist-info/RECORD,,
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,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (70.2.0)
2
+ Generator: setuptools (71.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5