math-spec-mapping 0.2.6.6__py3-none-any.whl → 0.2.7__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,3 +15,4 @@ class ControlActionOption:
15
15
  self.name = data["name"]
16
16
  self.description = data["description"]
17
17
  self.logic = data["logic"]
18
+ self.implementations = data["implementations"]
@@ -4,6 +4,7 @@ from .Policy import Policy
4
4
  from .Mechanism import Mechanism
5
5
  from .ControlAction import ControlAction
6
6
  from .BoundaryAction import BoundaryAction
7
+ import os
7
8
 
8
9
 
9
10
  class MathSpec:
@@ -12,6 +13,7 @@ class MathSpec:
12
13
  self._ms_dict = ms_dict
13
14
  self._json = json
14
15
  self.type_keys = ms_dict["Type Keys"]
16
+ self.implementations = ms_dict["Implementations"]
15
17
  self.action_transmission_channels = ms_dict["Action Transmission Channels"]
16
18
  self.boundary_actions = ms_dict["Boundary Actions"]
17
19
  self.control_actions = ms_dict["Control Actions"]
@@ -349,3 +351,99 @@ class MathSpec:
349
351
  for metrics in self.stateful_metrics.values():
350
352
  sm.extend([x.name for x in metrics.metrics])
351
353
  return sm
354
+
355
+ def metaprogramming_python_types(self, model_directory, overwrite=False):
356
+ path = model_directory + "/types.py"
357
+ if not overwrite:
358
+ assert "types.py" not in os.listdir(
359
+ model_directory
360
+ ), "The types file is already written, either delete it or switch to overwrite mode"
361
+ out = "import typing\n\n"
362
+ for t in self.types:
363
+ t = self.types[t]
364
+ assert "python" in t.type, "No python type associated with {}".format(
365
+ t.name
366
+ )
367
+ x = t.type["python"]
368
+ type_desc = x.__name__ if hasattr(x, "__name__") else str(x)
369
+ out += "{} = {}".format(t.original_type_name, type_desc)
370
+ out += "\n"
371
+ with open(path, "w") as f:
372
+ f.write(out)
373
+
374
+ def metaprogramming_python_spaces(self, model_directory, overwrite=False):
375
+ path = model_directory + "/spaces.py"
376
+ if not overwrite:
377
+ assert "spaces.py" not in os.listdir(
378
+ model_directory
379
+ ), "The spaces file is already written, either delete it or switch to overwrite mode"
380
+ unique_spaces = set().union(
381
+ *[set(x.schema.values()) for x in self.spaces.values()]
382
+ )
383
+ unique_types = [x.original_type_name for x in unique_spaces]
384
+ out = ""
385
+ out += "from .types import {}".format(", ".join(unique_types))
386
+ out += "\n"
387
+ out += "from typing import TypedDict"
388
+ out += "\n"
389
+ out += "\n"
390
+
391
+ for space in self.spaces:
392
+ out += self.spaces[space].name_variable
393
+ out += " = "
394
+ d = self.spaces[space].schema
395
+ d = [(x, d[x].original_type_name) for x in d]
396
+ d = ["'{}': {}".format(x[0], x[1]) for x in d]
397
+ d = ", ".join(d)
398
+ d = "{" + d + "}"
399
+ out += "TypedDict('{}', {})".format(self.spaces[space].name, d)
400
+ out += "\n"
401
+
402
+ with open(path, "w") as f:
403
+ f.write(out)
404
+
405
+ def metaprogramming_python_states(
406
+ self, model_directory, overwrite=False, default_values=None
407
+ ):
408
+ path = model_directory + "/states.py"
409
+ if not overwrite:
410
+ assert "states.py" not in os.listdir(
411
+ model_directory
412
+ ), "The states file is already written, either delete it or switch to overwrite mode"
413
+ out = ""
414
+ unique_types = [x.variables for x in self.state.values()]
415
+ unique_types = [set(y.type.original_type_name for y in x) for x in unique_types]
416
+ unique_types = set().union(*unique_types)
417
+ out = ""
418
+ out += "from .types import {}".format(", ".join(unique_types))
419
+ out += "\n"
420
+ out += "from typing import TypedDict"
421
+ out += "\n"
422
+ out += "\n"
423
+
424
+ for state in self.state:
425
+ out += self.state[state].name_variable
426
+ out += " = "
427
+ d = self.state[state].variables
428
+ d = [(x.name, x.type.original_type_name) for x in d]
429
+ d = ["'{}': {}".format(x[0], x[1]) for x in d]
430
+ d = ", ".join(d)
431
+ d = "{" + d + "}"
432
+ out += "TypedDict('{}', {})".format(self.state[state].name, d)
433
+ out += "\n"
434
+ out += "\n"
435
+ out += "state: GlobalState = "
436
+ out += "{"
437
+ for x in self.state["Global State"].variables:
438
+ out += '"{}"'.format(x.name)
439
+ out += ": "
440
+ val = "None"
441
+ if default_values:
442
+ if x.name in default_values:
443
+ val = str(default_values[x.name])
444
+ out += val
445
+ out += ",\n"
446
+ out += "}"
447
+
448
+ with open(path, "w") as f:
449
+ f.write(out)
@@ -10,3 +10,4 @@ class Mechanism(Block):
10
10
  self.logic = data["logic"]
11
11
  self.updates = []
12
12
  self.block_type = "Mechanism"
13
+ self.implementations = data["implementations"]
@@ -7,6 +7,7 @@ class PolicyOption:
7
7
  self.name = data["name"]
8
8
  self.description = data["description"]
9
9
  self.logic = data["logic"]
10
+ self.implementations = data["implementations"]
10
11
 
11
12
 
12
13
  class Policy(Block):
@@ -6,6 +6,7 @@ class Space:
6
6
  self.name = data["name"]
7
7
  self.schema = data["schema"]
8
8
  self.metadata = data["metadata"]
9
+ self.name_variable = self.name.replace(" ", "").replace("-", "_")
9
10
 
10
11
  def __repr__(self):
11
12
  return self.name
@@ -15,6 +15,7 @@ class State:
15
15
  self._write_variable_map()
16
16
  self.updated_by = []
17
17
  self.metadata = data["metadata"]
18
+ self.name_variable = self.name.replace(" ", "").replace("-", "_")
18
19
 
19
20
  def _write_variable_map(self) -> None:
20
21
  """
@@ -6,3 +6,4 @@ class Type:
6
6
  self.type_name = data["type_name"]
7
7
  self.notes = data["notes"]
8
8
  self.metadata = data["metadata"]
9
+ self.original_type_name = data["original_type_name"]
@@ -35,6 +35,16 @@ def convert_control_action(data: Dict, ms: Dict) -> ControlAction:
35
35
  new_cao = []
36
36
  for ca in data["control_action_options"]:
37
37
  check_json_keys(ca, "Control Action Option")
38
+ ca["implementations"] = {}
39
+ if "python" in ms["Implementations"]:
40
+ if "control_action_options" in ms["Implementations"]["python"]:
41
+ if (
42
+ ca["name"]
43
+ in ms["Implementations"]["python"]["control_action_options"]
44
+ ):
45
+ ca["implementations"]["python"] = ms["Implementations"]["python"][
46
+ "control_action_options"
47
+ ][ca["name"]]
38
48
  new_cao.append(ControlActionOption(ca))
39
49
  data["control_action_options"] = new_cao
40
50
 
@@ -42,6 +42,14 @@ def convert_mechanism(data: Dict, ms: Dict) -> Mechanism:
42
42
  )
43
43
 
44
44
  data["domain"] = tuple(ms["Spaces"][x] for x in data["domain"])
45
+ data["implementations"] = {}
46
+
47
+ if "python" in ms["Implementations"]:
48
+ if "mechanisms" in ms["Implementations"]["python"]:
49
+ if data["name"] in ms["Implementations"]["python"]["mechanisms"]:
50
+ data["implementations"]["python"] = ms["Implementations"]["python"][
51
+ "mechanisms"
52
+ ][data["name"]]
45
53
 
46
54
  # Build the action transmission channel object
47
55
  return Mechanism(data), new_channels
@@ -5,7 +5,7 @@ from ..Classes import Policy, PolicyOption
5
5
  from .general import check_json_keys
6
6
 
7
7
 
8
- def convert_policy_options(data: Dict) -> PolicyOption:
8
+ def convert_policy_options(data: Dict, ms) -> PolicyOption:
9
9
  """Function to convert policy options
10
10
 
11
11
  Args:
@@ -21,6 +21,15 @@ def convert_policy_options(data: Dict) -> PolicyOption:
21
21
  # Copy
22
22
  data = data.copy()
23
23
 
24
+ data["implementations"] = {}
25
+
26
+ if "python" in ms["Implementations"]:
27
+ if "policies" in ms["Implementations"]["python"]:
28
+ if data["name"] in ms["Implementations"]["python"]["policies"]:
29
+ data["implementations"]["python"] = ms["Implementations"]["python"][
30
+ "policies"
31
+ ][data["name"]]
32
+
24
33
  # Build the policy object
25
34
  return PolicyOption(data)
26
35
 
@@ -62,7 +71,7 @@ def convert_policy(data: Dict, ms: Dict) -> Policy:
62
71
  # Convert policy options
63
72
  policy_options = []
64
73
  for po in data["policy_options"]:
65
- policy_options.append(convert_policy_options(po))
74
+ policy_options.append(convert_policy_options(po, ms))
66
75
  data["policy_options"] = policy_options
67
76
 
68
77
  data["codomain"] = tuple(ms["Spaces"][x] for x in data["codomain"])
@@ -18,6 +18,7 @@ def convert_type(data, ms):
18
18
  type_name = data["type"]
19
19
  data["type"] = {}
20
20
  data["type_name"] = {}
21
+ data["original_type_name"] = type_name
21
22
 
22
23
  if "python" in ms["Type Keys"]:
23
24
 
@@ -9,6 +9,7 @@ from .node_map import create_action_chains_graph
9
9
  from .parameters import write_out_params
10
10
  from .state import write_local_state_variable_tables, write_global_state_variable_table
11
11
  from typing import List
12
+ import os
12
13
 
13
14
 
14
15
  def write_basic_report_full(ms: MathSpec, directory: str, name: str) -> None:
@@ -128,6 +129,15 @@ def write_spec_tree(
128
129
  symbol3 = "│ │ ├──"
129
130
 
130
131
  out = ""
132
+
133
+ if linking:
134
+ out += """---
135
+ cssclasses:
136
+ - spec
137
+ ---
138
+
139
+ """
140
+
131
141
  out += symbol1 + "**Entities**\n"
132
142
  for name in ms.entities.keys():
133
143
  if linking:
@@ -214,7 +224,29 @@ def write_spec_tree(
214
224
  if path:
215
225
  with open("{}/Spec Tree.md".format(path), "w") as f:
216
226
  f.write(out)
217
- return out
227
+ try:
228
+ if ".obsidian" not in os.listdir(path):
229
+ path = path + "/" + ".obsidian"
230
+ os.mkdir(path)
231
+ else:
232
+ path = path + "/" + ".obsidian"
233
+ if "snippets" not in os.listdir(path):
234
+ path = path + "/" + "snippets"
235
+ os.mkdir(path)
236
+ else:
237
+ path = path + "/" + "snippets"
238
+
239
+ snippet = """.spec {
240
+ font-family: 'Consolas', Courier, monospace ;
241
+ line-height: 1;
242
+ }"""
243
+ with open("{}/spec.css".format(path), "w") as f:
244
+ f.write(snippet)
245
+
246
+ except:
247
+ print("Couldn't find .obsidian/snippets to put snippet in")
248
+ else:
249
+ return out
218
250
 
219
251
 
220
252
  def write_overview(ms: MathSpec, name: str, file_path: str, summary: str = None):
@@ -0,0 +1,753 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-06/schema#",
3
+ "$ref": "./schema.schema.json/#/definitions/MSMLSpec",
4
+ "title": "MSML",
5
+ "$id": "https://github.com/BlockScience/MSML/src/schema.schema.json",
6
+ "definitions": {
7
+ "MSMLSpec": {
8
+ "type": "object",
9
+ "additionalProperties": false,
10
+ "properties": {
11
+ "Policies": {
12
+ "type": "array",
13
+ "items": {
14
+ "$ref": "./schema.schema.json/#/definitions/Policy"
15
+ }
16
+ },
17
+ "Spaces": {
18
+ "type": "array",
19
+ "items": {
20
+ "$ref": "./schema.schema.json/#/definitions/Space"
21
+ }
22
+ },
23
+ "State": {
24
+ "type": "array",
25
+ "items": {
26
+ "$ref": "./schema.schema.json/#/definitions/State"
27
+ }
28
+ },
29
+ "Stateful Metrics": {
30
+ "type": "array",
31
+ "items": {
32
+ "$ref": "./schema.schema.json/#/definitions/StatefulMetric"
33
+ }
34
+ },
35
+ "Parameters": {
36
+ "type": "array",
37
+ "items": {
38
+ "$ref": "./schema.schema.json/#/definitions/Parameter"
39
+ }
40
+ },
41
+ "Mechanisms": {
42
+ "type": "array",
43
+ "items": {
44
+ "$ref": "./schema.schema.json/#/definitions/Mechanism"
45
+ }
46
+ },
47
+ "Entities": {
48
+ "type": "array",
49
+ "items": {
50
+ "$ref": "./schema.schema.json/#/definitions/Entity"
51
+ }
52
+ },
53
+ "Boundary Actions": {
54
+ "type": "array",
55
+ "items": {
56
+ "$ref": "./schema.schema.json/#/definitions/BoundaryAction"
57
+ }
58
+ },
59
+ "Control Actions": {
60
+ "type": "array",
61
+ "items": {
62
+ "$ref": "./schema.schema.json/#/definitions/ControlAction"
63
+ }
64
+ },
65
+ "Wiring": {
66
+ "type": "array",
67
+ "items": {
68
+ "$ref": "./schema.schema.json/#/definitions/Wiring"
69
+ }
70
+ },
71
+ "Types": {
72
+ "type": "array",
73
+ "items": {
74
+ "$ref": "./schema.schema.json/#/definitions/Type"
75
+ }
76
+ },
77
+ "Metrics": {
78
+ "type": "array",
79
+ "items": {
80
+ "$ref": "./schema.schema.json/#/definitions/Metric"
81
+ }
82
+ },
83
+ "Displays": {"type": "object",
84
+ "additionalProperties": false,
85
+ "properties": {
86
+ "wiring": {
87
+ "type": "array",
88
+ "items": {
89
+ "$ref": "./schema.schema.json/#/definitions/WiringDisplay"
90
+ }
91
+ }
92
+ },
93
+ "required": [
94
+ "wiring"
95
+ ]}
96
+ },
97
+ "required": [
98
+ "Boundary Actions",
99
+ "Control Actions",
100
+ "Entities",
101
+ "Mechanisms",
102
+ "Parameters",
103
+ "Policies",
104
+ "Spaces",
105
+ "State",
106
+ "Stateful Metrics",
107
+ "Types",
108
+ "Wiring",
109
+ "Metrics"
110
+ ],
111
+ "title": "MSMLSpec",
112
+ "description": "A JSON schema that is used in the mathematical specification mapping library to create the underlying MSML object."
113
+ },
114
+ "ControlAction": {
115
+ "type": "object",
116
+ "additionalProperties": false,
117
+ "properties": {
118
+ "name": {
119
+ "type": "string"
120
+ },
121
+ "description": {
122
+ "type": "string"
123
+ },
124
+ "constraints": {
125
+ "type": "array",
126
+ "items": {}
127
+ },
128
+ "control_action_options": {
129
+ "type": "array",
130
+ "items": {}
131
+ },
132
+ "codomain": {
133
+ "type": "array",
134
+ "items": {
135
+ "type": "string"
136
+ }
137
+ },
138
+ "parameters_used": {
139
+ "type": "array",
140
+ "items": {"type": "string"}
141
+ }
142
+ },
143
+ "required": [
144
+ "codomain",
145
+ "constraints",
146
+ "control_action_options",
147
+ "description",
148
+ "name",
149
+ "parameters_used"
150
+ ],
151
+ "title": "ControlAction",
152
+ "description": "The definition of actions that the system might call, such as an action to refill the stock of an item when reserves run too low or something that could get triggered from a sensor. The key differentiator from boundary actions is that there is no entity calling it and it is not done with randomness."
153
+ },
154
+ "Entity": {
155
+ "type": "object",
156
+ "additionalProperties": false,
157
+ "properties": {
158
+ "name": {
159
+ "type": "string",
160
+ "description": "The name of the entity"
161
+ },
162
+ "notes": {
163
+ "type": "string",
164
+ "description": "Any notes on the entity"
165
+ },
166
+ "state": {
167
+ "type": "string",
168
+ "description": "The string key for the state associated with the entity"
169
+ },
170
+ "metadata": {"type": "object"}
171
+ },
172
+ "required": [
173
+ "name",
174
+ "notes",
175
+ "state"
176
+ ],
177
+ "title": "Entity",
178
+ "description": "Entities are any class of user or infrastructure that should have their own state and potentially ability to call boundary actions. Examples could be a customer or a company (for which a simulation might assume it is acting as one cohesive unit)"
179
+ },
180
+ "Mechanism": {
181
+ "type": "object",
182
+ "additionalProperties": false,
183
+ "properties": {
184
+ "name": {
185
+ "type": "string",
186
+ "description": "The name of the mechanism"
187
+ },
188
+ "description": {
189
+ "type": "string",
190
+ "description": "The description of what the mechanism does"
191
+ },
192
+ "constraints": {
193
+ "type": "array",
194
+ "description": "Any constraints which the mechanism must respect",
195
+ "items": {"type": "string"}
196
+ },
197
+ "logic": {
198
+ "type": "string",
199
+ "description": "The logic of how the mechanism should work"
200
+ },
201
+ "domain": {
202
+ "type": "array",
203
+ "items": {
204
+ "type": "string"
205
+ },
206
+ "description": "The spaces which are the input into the mechanism"
207
+ },
208
+ "parameters_used": {
209
+ "type": "array",
210
+ "items": {
211
+ "type": "string"
212
+ },
213
+ "description": "The string keys of parameters which have an effect on the mechanism"
214
+ },
215
+ "updates": {
216
+ "type": "array",
217
+ "items": {
218
+ "items": {
219
+ "$ref": "./schema.schema.json/#/definitions/Update"
220
+ }
221
+ },
222
+ "description": "The states updates that the mechanism causes in the form of (Entity, State Variable)"
223
+ },
224
+ "metadata": {"type": "object",
225
+ "description": "Any metadata that is added onto the mechanism"}
226
+ },
227
+ "required": [
228
+ "constraints",
229
+ "description",
230
+ "domain",
231
+ "logic",
232
+ "name",
233
+ "parameters_used",
234
+ "updates"
235
+ ],
236
+ "title": "Mechanism",
237
+ "description": "Anything that updates state in the system, usually policies will call these with the outputs of logic. The reasoning to split them out is so that if at some point you want to add a recording variable every time an account is changed or do something like have a variable listener, you can just change the mechanism responsible for it in only one place."
238
+ },
239
+ "Parameter": {
240
+ "type": "object",
241
+ "additionalProperties": false,
242
+ "properties": {
243
+ "name": {
244
+ "type": "string",
245
+ "description": "The name of the parameter set"
246
+ },
247
+ "notes": {
248
+ "type": "string",
249
+ "description": "Any notes about the parameter set"
250
+ },
251
+ "parameters": {
252
+ "type": "array",
253
+ "items": {
254
+ "$ref": "./schema.schema.json/#/definitions/ParameterElement"
255
+ },
256
+ "description": "All parameters that are a part of this parameter set"
257
+ }
258
+ },
259
+ "required": [
260
+ "name",
261
+ "notes",
262
+ "parameters"
263
+ ],
264
+ "title": "Parameter",
265
+ "description": "Both local and global parameter sets in the system that could be set"
266
+ },
267
+ "ParameterElement": {
268
+ "type": "object",
269
+ "additionalProperties": false,
270
+ "properties": {
271
+ "variable_type": {
272
+ "type": "string",
273
+ "description": "The type of that the parameter takes."
274
+ },
275
+ "name": {
276
+ "type": "string",
277
+ "description": "The unique name of the parameter"
278
+ },
279
+ "description": {
280
+ "type": "string",
281
+ "description": "The description of the parameter"
282
+ },
283
+ "symbol": {
284
+ "type": ["string","null"],
285
+ "description": "The symbol associated with the parameter (optional)"
286
+ },
287
+ "domain": {
288
+ "type": ["string","null"],
289
+ "description": "The mathematical domain of the parameter (optional)"
290
+ },
291
+ "parameter_class": {
292
+ "type": "string",
293
+ "description": "The type of paramter this is, of which the options are system (what you would find in production code of a system), behavioral (for what kinds of behavioral assumptions and distributions there are), and functional (for defining out different functional forms such as swapping in and out policies)"
294
+ }
295
+ },
296
+ "required": [
297
+ "description",
298
+ "domain",
299
+ "name",
300
+ "parameter_class",
301
+ "symbol",
302
+ "variable_type"
303
+ ],
304
+ "title": "ParameterElement"
305
+ },
306
+ "Policy": {
307
+ "type": "object",
308
+ "additionalProperties": false,
309
+ "properties": {
310
+ "name": {
311
+ "type": "string"
312
+ },
313
+ "description": {
314
+ "type": "string"
315
+ },
316
+ "constraints": {
317
+ "type": "array",
318
+ "items": {}
319
+ },
320
+ "policy_options": {
321
+ "type": "array",
322
+ "items": {
323
+ "$ref": "./schema.schema.json/#/definitions/PolicyOption"
324
+ }
325
+ },
326
+ "domain": {
327
+ "type": "array",
328
+ "items": {
329
+ "type": "string"
330
+ }
331
+ },
332
+ "codomain": {
333
+ "type": "array",
334
+ "items": {
335
+ "type": "string"
336
+ }
337
+ },
338
+ "parameters_used": {
339
+ "type": "array",
340
+ "items": {
341
+ "type": "string"
342
+ }
343
+ },
344
+ "metrics_used": {
345
+ "type": "array",
346
+ "items": {
347
+ "type": "string"
348
+ }
349
+ }
350
+ },
351
+ "required": [
352
+ "codomain",
353
+ "constraints",
354
+ "description",
355
+ "domain",
356
+ "name",
357
+ "parameters_used",
358
+ "policy_options",
359
+ "metrics_used"
360
+ ],
361
+ "title": "Policy",
362
+ "description": "A definition of the policies that handle all logical things. This could be, for example, a policy which determines what price is paid given a boundary action of someone putting in a market buy order for a stock."
363
+ },
364
+ "PolicyOption": {
365
+ "type": "object",
366
+ "additionalProperties": false,
367
+ "properties": {
368
+ "name": {
369
+ "type": "string"
370
+ },
371
+ "description": {
372
+ "type": "string"
373
+ },
374
+ "logic": {
375
+ "type": "string"
376
+ }
377
+ },
378
+ "required": [
379
+ "description",
380
+ "logic",
381
+ "name"
382
+ ],
383
+ "title": "PolicyOption",
384
+ "description": "The concrete possible implementations that a given policy block can reference or select"
385
+ },
386
+ "Space": {
387
+ "type": "object",
388
+ "additionalProperties": false,
389
+ "properties": {
390
+ "name": {
391
+ "type": "string"
392
+ },
393
+ "schema": {
394
+ "$ref": "./schema.schema.json/#/definitions/Schema"
395
+ }
396
+ },
397
+ "required": [
398
+ "name",
399
+ "schema"
400
+ ],
401
+ "title": "Space",
402
+ "description": "Spaces are similar to types in that they define a schema for data and are used as the domain/codomain for different blocks. They can be thought of as typed dictionaries."
403
+ },
404
+ "StatefulMetric": {
405
+ "type": "object",
406
+ "additionalProperties": true,
407
+ "properties": {
408
+ "name": {
409
+ "type": "string",
410
+ "description": "The name of the stateful metric set"
411
+ },
412
+ "notes": {
413
+ "type": "string",
414
+ "description": "Any notes about the stateful metric set"
415
+ },
416
+ "metrics": {
417
+ "type": "array",
418
+ "items": {
419
+ "$ref": "./schema.schema.json/#/definitions/StatefulMetricVar",
420
+ "description": "All the attatched stateful metrics"
421
+ }
422
+ }
423
+ },
424
+ "required": [
425
+ "metrics",
426
+ "name",
427
+ "notes"
428
+ ],
429
+ "title": "Stateful Metric",
430
+ "description": "Variables that are not held directly in the state but can computed from the state & parameters."
431
+ },
432
+ "BoundaryAction": {
433
+ "type": "object",
434
+ "additionalProperties": true,
435
+ "properties": {
436
+ "name": {
437
+ "type": "string"
438
+ },
439
+ "description": {
440
+ "type": "string"
441
+ },
442
+ "constraints": {
443
+ "type": "array",
444
+ "items": {
445
+ "type": "string"
446
+ }
447
+ },
448
+ "boundary_action_options": {
449
+ "type": "array",
450
+ "items": {}
451
+ },
452
+ "called_by": {
453
+ "type": "array",
454
+ "items": {
455
+ "type": "string"
456
+ }
457
+ },
458
+ "codomain": {
459
+ "type": "array",
460
+ "items": {
461
+ "type": "string"
462
+ }
463
+ },
464
+ "parameters_used": {
465
+ "type": "array",
466
+ "items": {
467
+ "type": "string"
468
+ }
469
+ }
470
+ },
471
+ "required": [
472
+ "boundary_action_options",
473
+ "called_by",
474
+ "codomain",
475
+ "constraints",
476
+ "description",
477
+ "name",
478
+ "parameters_used"
479
+ ],
480
+ "title": "Boundary Action",
481
+ "description": "The definition of different actions that might happen outside of the system such as customers coming into a shop. Generally will be called by entities."
482
+ },
483
+ "Schema": {
484
+ "type": "object",
485
+ "additionalProperties": true,
486
+ "required": [],
487
+ "title": "Schema"
488
+ },
489
+ "State": {
490
+ "type": "object",
491
+ "additionalProperties": false,
492
+ "properties": {
493
+ "name": {
494
+ "type": "string",
495
+ "description": "Any notes about the state or its implementation"
496
+ },
497
+ "notes": {
498
+ "type": "string",
499
+ "description": "The name of the state"
500
+ },
501
+ "variables": {
502
+ "type": "array",
503
+ "items": {
504
+ "$ref": "./schema.schema.json/#/definitions/Variable"
505
+ },
506
+ "description": "All the attatched state variables for the component"
507
+ }
508
+ },
509
+ "required": [
510
+ "name",
511
+ "notes",
512
+ "variables"
513
+ ],
514
+ "title": "State",
515
+ "description": "The definition of states in the system. There is one global system state and then the rest of the definitions are local states, generally for recording what entity states there are."
516
+ },
517
+ "Variable": {
518
+ "type": "object",
519
+ "additionalProperties": false,
520
+ "properties": {
521
+ "type": {
522
+ "type": "string",
523
+ "description": "The type of the variable"
524
+ },
525
+ "name": {
526
+ "type": "string",
527
+ "description": "Variable name"
528
+ },
529
+ "description": {
530
+ "type": "string",
531
+ "description": "Description of what the variable is"
532
+ },
533
+ "symbol": {
534
+ "type": ["string","null"],
535
+ "description": "The symbol associated with the parameter (optional)"
536
+ },
537
+ "domain": {
538
+ "type": ["string","null"],
539
+ "description": "The mathematical domain of the parameter (optional)"
540
+ }
541
+ },
542
+ "required": [
543
+ "description",
544
+ "domain",
545
+ "name",
546
+ "symbol",
547
+ "type"
548
+ ],
549
+ "title": "Variable"
550
+ },
551
+ "Type": {
552
+ "type": "object",
553
+ "additionalProperties": false,
554
+ "properties": {
555
+ "name": {
556
+ "type": "string"
557
+ },
558
+ "type": {
559
+ "type": "string"
560
+ },
561
+ "notes": {
562
+ "type": "string"
563
+ },
564
+ "metadata": {"type": "object"}
565
+ },
566
+ "required": [
567
+ "name",
568
+ "notes",
569
+ "type"
570
+ ],
571
+ "title": "Type",
572
+ "description": "This is for defining what a type might in its most basic form. These could be single typings or compound typings. The point here is to allow for changing typing in one single place and having it flow through anywhere else. I.e. if one were to define the currency type as USD, but then the project switched to using EUR, it would just require changing currency to be EUR."
573
+ },
574
+ "Metric": {
575
+ "type": "object",
576
+ "additionalProperties": false,
577
+ "properties": {
578
+ "type": {
579
+ "type": "string"
580
+ },
581
+ "name": {
582
+ "type": "string"
583
+ },
584
+ "description": {
585
+ "type": "string"
586
+ },
587
+ "variables_used": {
588
+ "type": "array",
589
+ "items": {
590
+ "type": "array",
591
+ "items": {
592
+ "type": "string"
593
+ }
594
+ }
595
+ },
596
+ "parameters_used": {
597
+ "type": "array",
598
+ "items": {
599
+ "type": "string"
600
+ }
601
+ },
602
+ "metrics_used": {
603
+ "type": "array",
604
+ "items": {
605
+ "type": "string"
606
+ }
607
+ },
608
+ "domain": {
609
+ "type": "array",
610
+ "items": {
611
+ "type": "string"
612
+ }
613
+ },
614
+ "logic": {
615
+ "type": "string"
616
+ },
617
+ "symbol": {
618
+ "type": ["string", "null"]
619
+ }
620
+ },
621
+ "required": [
622
+ "description",
623
+ "domain",
624
+ "logic",
625
+ "name",
626
+ "parameters_used",
627
+ "symbol",
628
+ "type",
629
+ "variables_used",
630
+ "metrics_used"
631
+ ],
632
+ "title": "Metric",
633
+ "description": "This component takes a variety of potential inputs and creates a metric from it. This can be used for defining out system success metrics or trying to modularize certain calculations that are needed across many other system components."
634
+ },
635
+ "Wiring": {
636
+ "type": "object",
637
+ "additionalProperties": false,
638
+ "properties": {
639
+ "name": {
640
+ "type": "string"
641
+ },
642
+ "components": {
643
+ "type": "array",
644
+ "items": {
645
+ "type": "string"
646
+ }
647
+ },
648
+ "description": {
649
+ "type": "string"
650
+ },
651
+ "constraints": {
652
+ "type": "array",
653
+ "items": {}
654
+ },
655
+ "type": {
656
+ "$ref": "./schema.schema.json/#/definitions/TypeEnum"
657
+ },
658
+ "mermaid_show_name": {
659
+ "type": "boolean"
660
+ },
661
+ "loop": {
662
+ "type": "boolean"
663
+ },
664
+ "optional_indices": {
665
+ "type": "array",
666
+ "items": {
667
+ "type": "integer"
668
+ }
669
+ }
670
+ },
671
+ "required": [
672
+ "components",
673
+ "constraints",
674
+ "description",
675
+ "name",
676
+ "type"
677
+ ],
678
+ "title": "Wiring",
679
+ "description": "A wiring is a block composed of other blocks with specific behaviors or orders of execution. For instance, there can be wirings that have blocks run one after another, passing their codomains to the next block's domain. There can also be wirings for blocks that all should run in parallel."
680
+ },
681
+ "Update": {
682
+ "title": "Update"
683
+ },
684
+ "TypeEnum": {
685
+ "type": "string",
686
+ "enum": [
687
+ "Parallel",
688
+ "Stack"
689
+ ],
690
+ "title": "TypeEnum"
691
+ },
692
+ "WiringDisplay": {"type": "object",
693
+ "additionalProperties": false,
694
+ "properties": {
695
+ "name": {
696
+ "type": "string"
697
+ },
698
+ "description": {
699
+ "type": "string"
700
+ },
701
+ "components": {
702
+ "type": "array",
703
+ "items": {
704
+ "type": "string"
705
+ }
706
+ }
707
+ },
708
+ "required": [
709
+ "components",
710
+ "name",
711
+ "description"
712
+ ]},
713
+ "StatefulMetricVar": {"type": "object",
714
+ "additionalProperties": false,
715
+ "properties": {
716
+ "type": {
717
+ "type": "string",
718
+ "description": "The type of the metric variable"
719
+ },
720
+ "name": {
721
+ "type": "string",
722
+ "description": "The name of the stateful metric variable"
723
+ },
724
+ "description": {
725
+ "type": "string",
726
+ "description": "The description of the computation"
727
+ },
728
+ "variables_used": {
729
+ "type": "array",
730
+ "items": {
731
+
732
+ },
733
+ "description": "The variables used for computation of the form (state, variable)"
734
+ },
735
+ "parameters_used": {
736
+ "type": "array",
737
+ "items": {
738
+ "type": "string",
739
+ "description": "The string keys of parameters which are used in the metric calculation"
740
+ }
741
+ },
742
+ "symbol": {
743
+ "type": ["string","null"],
744
+ "description": "The symbol associated with the stateful metric (optional)"
745
+ },
746
+ "domain": {
747
+ "type": ["string","null"],
748
+ "description": "The mathematical domain of the stateful metric (optional)"
749
+ }
750
+ }
751
+ }
752
+ }
753
+ }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: math-spec-mapping
3
- Version: 0.2.6.6
3
+ Version: 0.2.7
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,20 +1,21 @@
1
1
  math_spec_mapping/__init__.py,sha256=k5KVhqX1_iIkGjTBHAHezWUeh0b3ilWpJaSIVSbKMcg,907
2
2
  math_spec_mapping/schema.py,sha256=6mrRqzEnTTSXjb19xJ63MBp0KjKH0s7i6TfT4MkAY9k,233
3
+ math_spec_mapping/schema.schema.json,sha256=E8-TQIiv7AjIMXnAIB84z_O4cMLfGuDmDCFCoIlwQz0,27174
3
4
  math_spec_mapping/Classes/ActionTransmissionChannel.py,sha256=zWMo5QsgPh5WGIWXl-xOrZNMXYJXmK6Vejw1dQvi0og,246
4
5
  math_spec_mapping/Classes/Block.py,sha256=hXQO221IP-TqZm_TwFKfURpEEjZm7L1TPZDCYlaOdho,17302
5
6
  math_spec_mapping/Classes/BoundaryAction.py,sha256=AOENCqCEfpjotnHhzUj_F2SOP0SGpkN1tNPr8Mtl6Tc,476
6
- math_spec_mapping/Classes/ControlAction.py,sha256=xaU3_WVeWOoOFX3O86x30_9Eiirfe76KrO3M2kfjcmo,471
7
+ math_spec_mapping/Classes/ControlAction.py,sha256=ysqpgANwdizVdwqtgZmnxXMpCqrzmVEF_6YT0M3l4Ho,526
7
8
  math_spec_mapping/Classes/Entity.py,sha256=fA0-b128_OHHxfCg4pzqyQV083EYev1HlVpy86S5igg,1226
8
- math_spec_mapping/Classes/MathSpec.py,sha256=P4FPfv6tpbrY1ytmOQ61hXBey83YoCMgMKOpo6xikxU,13230
9
- math_spec_mapping/Classes/Mechanism.py,sha256=7jj6bcPI6H2iv1VZZTlpbG4G2k9s4MYkrH8Sfj9uGM4,324
9
+ math_spec_mapping/Classes/MathSpec.py,sha256=eweFUB8iuEI5Y-9VOULbAWbIeHd18Iw-I_VPUjvnn0E,16999
10
+ math_spec_mapping/Classes/Mechanism.py,sha256=2sLm3wYBIeTQaMBcsJ9btqIWsbS895Ra8NY6Y9_G_Dg,379
10
11
  math_spec_mapping/Classes/Metric.py,sha256=AhPgYppOP6q49xvR8S9STxQsXUKJlTWx7wI1LfZEtww,581
11
12
  math_spec_mapping/Classes/Parameter.py,sha256=ZuJ_w0sChvRElJ4sOnXZ2EV4Ell2xXFulKLjVOpgz2E,1237
12
- math_spec_mapping/Classes/Policy.py,sha256=HUEooO4Liy7olmHwegb6A-hcreNMNCevl9QKKwOjSik,475
13
- math_spec_mapping/Classes/Space.py,sha256=96Cdi8ERkfsgJnh5UyhecKiuU4hWwI6w-i1U1jtwX6A,398
14
- math_spec_mapping/Classes/State.py,sha256=Mdn0D21G198f6q13-2tVBYUbnzhRwoDivWpFtH4XJq0,1423
13
+ math_spec_mapping/Classes/Policy.py,sha256=fzV85tB3QScjiYGfhw_dyQt9L1BYYfTyTIQQcxeT8ac,530
14
+ math_spec_mapping/Classes/Space.py,sha256=QsahxoUfRsDWQLBL683KnGx72MAmRxv7CDE7TMgCG-E,472
15
+ math_spec_mapping/Classes/State.py,sha256=0gJHHTNjTrz1fL2K-yPu-dJlaCsU_NMxClw6neDv6gE,1497
15
16
  math_spec_mapping/Classes/StateUpdateTransmissionChannel.py,sha256=3hBLvD1lE64PkwqksBXAfFWv7foOZzGQLAFQWy42tOA,257
16
17
  math_spec_mapping/Classes/StatefulMetric.py,sha256=UCis1BJ7fsajHHxFF05ZiyDean2D4s4a95uYYW1Mjq4,749
17
- math_spec_mapping/Classes/Type.py,sha256=ZDHSiaDixHOxasOJlHbuBsMjZ29O2O5K_nmHOmlO-Ck,228
18
+ math_spec_mapping/Classes/Type.py,sha256=2KFY8d3cv1PzJJ7SSMHJf1zcfQ3ZbqxotK2KgTaLZdM,289
18
19
  math_spec_mapping/Classes/__init__.py,sha256=_hXyZMJanmIex_W6yCR2H7Jw8iU2JJIf3U7VcvBSOGU,737
19
20
  math_spec_mapping/Convenience/__init__.py,sha256=-hNZVoaNSgTmZTiyZoMfWyg14xonC3ppz-diQk1VlUY,60
20
21
  math_spec_mapping/Convenience/documentation.py,sha256=Jf7-JJIk_vZkNBIGV4bs5LM3B0RVaCCtuwJ164thGfY,1607
@@ -22,27 +23,27 @@ math_spec_mapping/Convenience/starter.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NM
22
23
  math_spec_mapping/Load/__init__.py,sha256=_ga5nHi7U5rY5lCF36_XI9Qmybq4P8R4m5I5mmjLBk8,33
23
24
  math_spec_mapping/Load/action_transmission_channel.py,sha256=9Wer7g2s5SSOcUYuZ0PqSKUVVnW3EvGQJZNXJTwW__0,2561
24
25
  math_spec_mapping/Load/boundary_actions.py,sha256=WvEj2tqN0pUZtE4EiKUuGzMdAcWsMlLslJJeFjIu6gk,2058
25
- math_spec_mapping/Load/control_actions.py,sha256=VmjezReijEqe9cdPHQubGZTGVPsYbMzWfLu5Dfm9WvY,1563
26
+ math_spec_mapping/Load/control_actions.py,sha256=4E57s730W4tX5SaKXKaAvet37r8Bwt-g8Kk6EanF4TU,2042
26
27
  math_spec_mapping/Load/displays.py,sha256=ooHWT_OryzEkp7F3LcGywwdLMRJLxuyPK82zJ3gcyN0,414
27
28
  math_spec_mapping/Load/entities.py,sha256=rMD_Pja-zqH1Z14rsO_Ia7dg3BIi5_HoQmqGAoEYofA,1208
28
29
  math_spec_mapping/Load/general.py,sha256=2q6aGKxXhebiHHTZhtACvM4nWIkTben0o5rXuvfv2Vw,4463
29
30
  math_spec_mapping/Load/implementations.py,sha256=SGKZ_YXeNpJUTnw5fajQTXji7S2bNQo8sh-7YcIO6pk,395
30
31
  math_spec_mapping/Load/load.py,sha256=CLprDhJpbwm9RAzKM2Ghwr8eqBu0a-wvGDOCMmc01YE,2484
31
- math_spec_mapping/Load/mechanism.py,sha256=aIpMzgQn8f1aywgOHxL5kHQUn1N8K9pmHOVs51bv3Hk,1673
32
+ math_spec_mapping/Load/mechanism.py,sha256=JBy-QpB4W0Z2OcNiakONjD4_RtEgxlFKtLXfDqfhR-0,2037
32
33
  math_spec_mapping/Load/metrics.py,sha256=gD68mt0Y5jSgofZUwscV8PFatOMV_LPwYyPrwV9SdtE,3273
33
34
  math_spec_mapping/Load/parameters.py,sha256=aid_vqYub9643s82NDtMAXLRdV9BPQkri5MadA0L0eQ,1334
34
- math_spec_mapping/Load/policy.py,sha256=fDBuOe1LWw-6C_xcYtvtx9dpjWoD9GNEumW7bK8QaT0,2077
35
+ math_spec_mapping/Load/policy.py,sha256=HvlhGHGJTweVs7DOI2HSL_2_diECr8ukDUmzoFLQELo,2444
35
36
  math_spec_mapping/Load/spaces.py,sha256=7zgGA57Te7T4hfuCCDElffiidWgn1lKm5E14e1yjt8M,1116
36
37
  math_spec_mapping/Load/state_update_transmission_channels.py,sha256=FJWp5n4HdtHAfof5BUQ6BnRakljatL2h8dWCapaVSc0,2238
37
38
  math_spec_mapping/Load/stateful_metrics.py,sha256=uGSTc6x6lld5xptgSUMHrO0Vg0QDRIL14C6zTg33S8o,1977
38
39
  math_spec_mapping/Load/states.py,sha256=cwo29SBAtj1FoQLEb8c0wkSCn038lIgM9RjNiZefUaE,1223
39
- math_spec_mapping/Load/type.py,sha256=R6d5t55TMMCKsOk8xXp_Cu5gvkt2DG4Yzvq6NREIefs,4174
40
+ math_spec_mapping/Load/type.py,sha256=Wq2EYTofuq4v8_jGGSr23IXJjwavLMjsqSEyhX9VoAM,4217
40
41
  math_spec_mapping/Load/wiring.py,sha256=1dR94U5N1W_WI5rL6lYBltH25ZvApB2pIpq9r5Opkug,3083
41
42
  math_spec_mapping/Reports/__init__.py,sha256=W27I6S9Ro1hWeHmnxIokCA06awB__eYey7PvKD4Hc1s,933
42
43
  math_spec_mapping/Reports/boundary_actions.py,sha256=45BPp4QjWdD-3E9ZWwqgj_nI2-YdcI2ZZ19_Qv_K7Qk,1410
43
44
  math_spec_mapping/Reports/control_actions.py,sha256=NksekZKIPFSIkubttFstKFthc5AU9B9PWRLSl9j1wWs,1216
44
45
  math_spec_mapping/Reports/general.py,sha256=WOOn6Wlb8M4fsdN49FlKLwOka6vJPQ9aCUy88TL2ki0,1610
45
- math_spec_mapping/Reports/html.py,sha256=rBnwvWeFgCfP7O8nsBL6hWE63Y1Qd24QyGD2Z7CnZ-8,8094
46
+ math_spec_mapping/Reports/html.py,sha256=xf5jk3DHWg4CfZHZuF2JK5iZ515ecjDShJJsahiqb4g,8882
46
47
  math_spec_mapping/Reports/markdown.py,sha256=pDGHYMdtZmeXHqvU9FB3BycyB4qflWXq0bf2m-wsXMU,21138
47
48
  math_spec_mapping/Reports/mechanisms.py,sha256=d2Rxt3JBYvqAOAYUynl0buYVoXEHrO8EGq7GK6hK8NA,1322
48
49
  math_spec_mapping/Reports/node_map.py,sha256=FdSMDQG16NX6n9sZcH-T5xwsvgjrV9OqBHc9J_VlNK0,3129
@@ -52,8 +53,8 @@ math_spec_mapping/Reports/spaces.py,sha256=-76hR5wQBv4lsG000ypBJ-OprjsNjI-rNRMYd
52
53
  math_spec_mapping/Reports/state.py,sha256=RSHDjzSiUj4ZjReWbkBW7k2njs3Ovp-q0rCC7GBfD-A,2203
53
54
  math_spec_mapping/Reports/tables.py,sha256=O0CNuqh3LMECq5uLjBOoxMUk5hUvkUK660FNnwWUxDY,1505
54
55
  math_spec_mapping/Reports/wiring.py,sha256=u9SvKWy6T-WJUEgFI6-zgZanoOaTTs_2YwmEceDLsV8,1618
55
- math_spec_mapping-0.2.6.6.dist-info/LICENSE,sha256=ObyEzSw8kgCaFbEfpu1zP4TrcAKLA0xhqHMZZfyh7N0,1069
56
- math_spec_mapping-0.2.6.6.dist-info/METADATA,sha256=pmXfVgcEFyYxic1tR3PR1CzdeSGj04T18uzG2KASngY,6014
57
- math_spec_mapping-0.2.6.6.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
58
- math_spec_mapping-0.2.6.6.dist-info/top_level.txt,sha256=AImhn9wgazkdV0a9vfiphtQR8uGe2nq-ZIOp-6yUk9o,18
59
- math_spec_mapping-0.2.6.6.dist-info/RECORD,,
56
+ math_spec_mapping-0.2.7.dist-info/LICENSE,sha256=ObyEzSw8kgCaFbEfpu1zP4TrcAKLA0xhqHMZZfyh7N0,1069
57
+ math_spec_mapping-0.2.7.dist-info/METADATA,sha256=H3plPQQrT7sss_57Z2341oAlBkMpW7_QHihqFoZcgUM,6012
58
+ math_spec_mapping-0.2.7.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
59
+ math_spec_mapping-0.2.7.dist-info/top_level.txt,sha256=AImhn9wgazkdV0a9vfiphtQR8uGe2nq-ZIOp-6yUk9o,18
60
+ math_spec_mapping-0.2.7.dist-info/RECORD,,