math-spec-mapping 0.3.20__py3-none-any.whl → 0.4.0__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 +3 -3
- math_spec_mapping/Classes/MathSpec.py +29 -0
- math_spec_mapping/Convenience/github.py +9 -0
- {math_spec_mapping-0.3.20.dist-info → math_spec_mapping-0.4.0.dist-info}/METADATA +11 -31
- {math_spec_mapping-0.3.20.dist-info → math_spec_mapping-0.4.0.dist-info}/RECORD +8 -8
- {math_spec_mapping-0.3.20.dist-info → math_spec_mapping-0.4.0.dist-info}/WHEEL +1 -1
- {math_spec_mapping-0.3.20.dist-info → math_spec_mapping-0.4.0.dist-info}/LICENSE +0 -0
- {math_spec_mapping-0.3.20.dist-info → math_spec_mapping-0.4.0.dist-info}/top_level.txt +0 -0
@@ -75,7 +75,7 @@ class Block:
|
|
75
75
|
if self.block_type == "Mechanism":
|
76
76
|
for u in sorted(self.updates, key=lambda x: x[0].name + "-" + x[1].name):
|
77
77
|
out += "\n"
|
78
|
-
out +=
|
78
|
+
out += 'X{} --"State Update"--> {}'.format(
|
79
79
|
i,
|
80
80
|
(u[0].name + "-" + u[1].name).replace(" ", "-"),
|
81
81
|
)
|
@@ -248,7 +248,7 @@ class ParallelBlock(Block):
|
|
248
248
|
self.all_updates, key=lambda x: x[0].name + "-" + x[1].name
|
249
249
|
):
|
250
250
|
out += "\n"
|
251
|
-
out +=
|
251
|
+
out += 'X{} --"State Update"--> {}'.format(
|
252
252
|
i,
|
253
253
|
(u[0].name + "-" + u[1].name).replace(" ", "-"),
|
254
254
|
)
|
@@ -445,7 +445,7 @@ class StackBlock(Block):
|
|
445
445
|
self.all_updates, key=lambda x: x[0].name + "-" + x[1].name
|
446
446
|
):
|
447
447
|
out += "\n"
|
448
|
-
out +=
|
448
|
+
out += 'X{} --"State Update"--> {}'.format(
|
449
449
|
i,
|
450
450
|
(u[0].name + "-" + u[1].name).replace(" ", "-"),
|
451
451
|
)
|
@@ -727,11 +727,13 @@ class MathSpec:
|
|
727
727
|
state_preperation_functions=None,
|
728
728
|
parameter_preperation_functions=None,
|
729
729
|
metrics_functions=None,
|
730
|
+
append_param_change_columns=False,
|
730
731
|
):
|
731
732
|
state_l = []
|
732
733
|
params_l = []
|
733
734
|
df_l = []
|
734
735
|
metrics_l = []
|
736
|
+
param_mods = set()
|
735
737
|
for experiment in experiments:
|
736
738
|
for i in range(experiment["Monte Carlo Runs"]):
|
737
739
|
state, params, msi, df, metrics = self.run_experiment(
|
@@ -743,6 +745,11 @@ class MathSpec:
|
|
743
745
|
parameter_preperation_functions=parameter_preperation_functions,
|
744
746
|
metrics_functions=metrics_functions,
|
745
747
|
)
|
748
|
+
if append_param_change_columns:
|
749
|
+
if experiment["Param Modifications"]:
|
750
|
+
for key in experiment["Param Modifications"]:
|
751
|
+
df[key] = experiment["Param Modifications"][key]
|
752
|
+
param_mods.add(key)
|
746
753
|
df["Monte Carlo Run"] = i + 1
|
747
754
|
df["Experiment"] = experiment["Name"]
|
748
755
|
metrics.loc["Monte Carlo Run"] = i + 1
|
@@ -753,6 +760,9 @@ class MathSpec:
|
|
753
760
|
df_l.append(df)
|
754
761
|
metrics_l.append(metrics)
|
755
762
|
df = pd.concat(df_l)
|
763
|
+
if append_param_change_columns:
|
764
|
+
for key in param_mods:
|
765
|
+
df[key] = df[key].fillna(params_base[key])
|
756
766
|
metrics = pd.concat(metrics_l, axis=1).T
|
757
767
|
return df, metrics, state_l, params_l
|
758
768
|
|
@@ -1022,6 +1032,12 @@ class MathSpecImplementation:
|
|
1022
1032
|
), "No functional parameterization for {}. To fix this error, add {} to the parameters passed to ms.build_implementation. Option can be: {}".format(
|
1023
1033
|
ca.name, "FP " + ca.name, [x.name for x in opts]
|
1024
1034
|
)
|
1035
|
+
assert (
|
1036
|
+
self.params["FP {}".format(ca.name)]
|
1037
|
+
in self.ms.functional_parameters["FP {}".format(ca.name)]
|
1038
|
+
), "{} is not a valid functional parameterization for {}".format(
|
1039
|
+
self.params["FP {}".format(ca.name)], ca.name
|
1040
|
+
)
|
1025
1041
|
opt = self.ms.functional_parameters["FP {}".format(ca.name)][
|
1026
1042
|
self.params["FP {}".format(ca.name)]
|
1027
1043
|
]
|
@@ -1061,6 +1077,13 @@ class MathSpecImplementation:
|
|
1061
1077
|
ba.name, "FP " + ba.name, [x.name for x in opts]
|
1062
1078
|
)
|
1063
1079
|
|
1080
|
+
assert (
|
1081
|
+
self.params["FP {}".format(ba.name)]
|
1082
|
+
in self.ms.functional_parameters["FP {}".format(ba.name)]
|
1083
|
+
), "{} is not a valid functional parameterization for {}".format(
|
1084
|
+
self.params["FP {}".format(ba.name)], ba.name
|
1085
|
+
)
|
1086
|
+
|
1064
1087
|
opt = self.ms.functional_parameters["FP {}".format(ba.name)][
|
1065
1088
|
self.params["FP {}".format(ba.name)]
|
1066
1089
|
]
|
@@ -1165,6 +1188,12 @@ class MathSpecImplementation:
|
|
1165
1188
|
), "No functional parameterization for {}. To fix this error, add {} to the parameters passed to ms.build_implementation. Option can be: {}".format(
|
1166
1189
|
p.name, "FP " + p.name, [x.name for x in opts]
|
1167
1190
|
)
|
1191
|
+
assert (
|
1192
|
+
self.params["FP {}".format(p.name)]
|
1193
|
+
in self.ms.functional_parameters["FP {}".format(p.name)]
|
1194
|
+
), "{} is not a valid functional parameterization for {}".format(
|
1195
|
+
self.params["FP {}".format(p.name)], p.name
|
1196
|
+
)
|
1168
1197
|
opt = self.ms.functional_parameters["FP {}".format(p.name)][
|
1169
1198
|
self.params["FP {}".format(p.name)]
|
1170
1199
|
]
|
@@ -92,6 +92,15 @@ def create_milestone_label_matrix(df, exclude_milestones=None):
|
|
92
92
|
labels = list(df.columns[4:])
|
93
93
|
labels = sorted([x for x in labels if x not in priority_labels])
|
94
94
|
milestones = sorted(list(df[~pd.isnull(df["Milestone"])]["Milestone"].unique()))
|
95
|
+
try:
|
96
|
+
milestones = sorted(
|
97
|
+
milestones,
|
98
|
+
key=lambda x: int(x.split(".")[0][1:]) * 10000
|
99
|
+
+ int(x.split(".")[1]) * 100
|
100
|
+
+ int(x.split(".")[2]),
|
101
|
+
)
|
102
|
+
except:
|
103
|
+
pass
|
95
104
|
|
96
105
|
table = []
|
97
106
|
for label in labels:
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: math-spec-mapping
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.4.0
|
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
|
@@ -13,7 +13,9 @@ Requires-Dist: graphviz>=0.20.1
|
|
13
13
|
Requires-Dist: ipython>=7.7.0
|
14
14
|
Requires-Dist: pandas>=1.4
|
15
15
|
|
16
|
-
# MSML
|
16
|
+
# Mathematical Specification Mapping Library (MSML)
|
17
|
+
|
18
|
+
For documentation and getting started with MSML, please refer to the site for MSML [here](https://blockscience.github.io/MSML/).
|
17
19
|
|
18
20
|
## What is the Mathematical Specification Mapping Library (MSML)?
|
19
21
|
|
@@ -21,7 +23,7 @@ MSML is a library for standardizing the creation of mathematical specifications
|
|
21
23
|
|
22
24
|
It uses block diagram wirings and spaces to represent the actions in complex systems in line with current BlockScience research on Generalized Dynamical Systems. It also adds some enhancements to the primitive blocks to represent richer sets of behaviors.
|
23
25
|
|
24
|
-
One good example is the [wiring report](https://github.com/
|
26
|
+
One good example is the [wiring report](https://github.com/BlockScience/Predator-Prey-MSML/blob/main/reports/obsidian/Wiring/Hunt%20Prey%20Wiring.md) for hunt prey wiring in the predator prey example (although it is best viewed in Obsidian where all the linking will work).
|
25
27
|
|
26
28
|
## Installing the library
|
27
29
|
|
@@ -31,6 +33,12 @@ To install the library, simply pip install by running "pip install math_spec_map
|
|
31
33
|
|
32
34
|
Writing mathematical specifications can be a difficult process, especially when variable names are changed or new mechanisms are introduced. MSML seeks to streamline the process with automations as well as enhance the abilities of static math specs to deliver deeper insights. Because it is automated, one can write specifications at different levels of details or for different purposes.
|
33
35
|
|
36
|
+
### Stakeholder Communications
|
37
|
+
|
38
|
+
- In organizations, senior people / non-developers don't always have as intimate a view of the underlying code as the primary developers in a system because of time constraints and not working as directly with the code as the primary developers
|
39
|
+
- Often this means that there is a reliance on asking the primary developers for clarifications and relying on "front-end" kinds of stuff such as visualizations or outputs of the model as opposed to combing through the underlying code
|
40
|
+
- MSML seeks to help bridge this gap by allowing for the Obsidian markdown vault that can showcase every component and its dependencies for easier consumption.... this reduces the barriers to entry on understanding the back-end/underlying model
|
41
|
+
- Also through things such as code linking, MSML allows for those with code fluency to jump into underlying code if they need to without even opening up the actual project repository
|
34
42
|
|
35
43
|
## What are some of the solutions offered?
|
36
44
|
|
@@ -79,34 +87,6 @@ Thanks to some of the more advanced features, MSML can be used as an aid for deb
|
|
79
87
|
|
80
88
|
The ability to fork the repository of an MSML spec as well as the ability to use it for A/B testing with the policy options makes it well suited for iterating on model evolution.
|
81
89
|
|
82
|
-
## Technical Details
|
83
|
-
|
84
|
-
The documentation on the technical details of using the MSML can be found [here](https://github.com/BlockScience/MSML/tree/main/docs)
|
85
|
-
|
86
|
-
## Canonical Examples
|
87
|
-
|
88
|
-
[Dummy/Starter Repository](https://github.com/BlockScience/MSML/tree/main/examples/StarterRepo)
|
89
|
-
[Root Finding Simulation](https://github.com/SeanMcOwen/Root-Finding-Simulation)
|
90
|
-
|
91
|
-
### Comparison of Canonical Example Features
|
92
|
-
|
93
|
-
| Feature | Dummy | Root Finding |
|
94
|
-
| --- | --- | --- |
|
95
|
-
| Action Transmission Channels | X | X |
|
96
|
-
| Stack Block | X | X |
|
97
|
-
| Parallel Block | | X |
|
98
|
-
| Split Block | | |
|
99
|
-
| Boundary Actions | X | |
|
100
|
-
| Control Actions | X | X |
|
101
|
-
| Entities | X | |
|
102
|
-
| Mechanisms | X | X |
|
103
|
-
| Parameters | X | X |
|
104
|
-
| Policies | X | X |
|
105
|
-
| Spaces | X | X |
|
106
|
-
| State | X | X |
|
107
|
-
| Stateful Metrics | | |
|
108
|
-
| State Update Transmission Channels | X | X |
|
109
|
-
| Reports | X | X |
|
110
90
|
|
111
91
|
## Other Related Repositories
|
112
92
|
|
@@ -2,11 +2,11 @@ math_spec_mapping/__init__.py,sha256=7fGuxoSDYl61z0PZ_PzS6x5P8l174gOzobI9u0aoLVw
|
|
2
2
|
math_spec_mapping/schema.py,sha256=6mrRqzEnTTSXjb19xJ63MBp0KjKH0s7i6TfT4MkAY9k,233
|
3
3
|
math_spec_mapping/schema.schema.json,sha256=NyzUy899YR_5Y956ID5HQtgnRBrNTAN6QjrqCyBasRA,31005
|
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=2VOBTPRafmtaLY847tEw3OJTrWNp2d0aSStC_u-JpbY,20195
|
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=
|
9
|
+
math_spec_mapping/Classes/MathSpec.py,sha256=h26RD-AIghj6B_7Sb5o9xDhrnPoSKd1FuZo6mHSa-7o,57522
|
10
10
|
math_spec_mapping/Classes/Mechanism.py,sha256=2sLm3wYBIeTQaMBcsJ9btqIWsbS895Ra8NY6Y9_G_Dg,379
|
11
11
|
math_spec_mapping/Classes/Metric.py,sha256=iQhH4g8Z60QlM22nPX9ytGmidOsZSiSs0KjqwmsScwU,636
|
12
12
|
math_spec_mapping/Classes/Parameter.py,sha256=ZuJ_w0sChvRElJ4sOnXZ2EV4Ell2xXFulKLjVOpgz2E,1237
|
@@ -19,7 +19,7 @@ math_spec_mapping/Classes/Type.py,sha256=cA5-5nOfjX6aHzTHM8M6mP5lsS7foumckRu7WDX
|
|
19
19
|
math_spec_mapping/Classes/__init__.py,sha256=0zxgOqns_9JybD74HKMVh6aw8ij8WVbfQ4Q_1uWzof0,761
|
20
20
|
math_spec_mapping/Convenience/__init__.py,sha256=BEZr1rXohKAknOa3wjNVx3EvSVxDcfftJsvtSw5mvmQ,264
|
21
21
|
math_spec_mapping/Convenience/documentation.py,sha256=1ziWVJznbCUxeAAt03nAdEYtMlXNo5TeedHfgs0vSBU,1625
|
22
|
-
math_spec_mapping/Convenience/github.py,sha256=
|
22
|
+
math_spec_mapping/Convenience/github.py,sha256=JMFJWyA3nRIMNYGvn9831BolnBthoa48HhgeZuENZm8,3772
|
23
23
|
math_spec_mapping/Convenience/starter.py,sha256=dD1R9wcVFZV-BCTflxNkR6Ay6NF1TlVBdIaWmbJwMGE,17379
|
24
24
|
math_spec_mapping/Load/__init__.py,sha256=QfHMLatZAKqj4up-LkDL_r42tO7Mo_-qdqPQYLYY5l0,49
|
25
25
|
math_spec_mapping/Load/action_transmission_channel.py,sha256=oTYCi7as4LWKZLxfRckuWpfLsAPZXjp-VBYmyLBN3yk,2781
|
@@ -55,8 +55,8 @@ math_spec_mapping/Reports/spaces.py,sha256=-76hR5wQBv4lsG000ypBJ-OprjsNjI-rNRMYd
|
|
55
55
|
math_spec_mapping/Reports/state.py,sha256=QYeCvX5cHeZBrbvMeDsTqJcUDTuDFJSLvPbasjLspk8,3643
|
56
56
|
math_spec_mapping/Reports/tables.py,sha256=O0CNuqh3LMECq5uLjBOoxMUk5hUvkUK660FNnwWUxDY,1505
|
57
57
|
math_spec_mapping/Reports/wiring.py,sha256=u9SvKWy6T-WJUEgFI6-zgZanoOaTTs_2YwmEceDLsV8,1618
|
58
|
-
math_spec_mapping-0.
|
59
|
-
math_spec_mapping-0.
|
60
|
-
math_spec_mapping-0.
|
61
|
-
math_spec_mapping-0.
|
62
|
-
math_spec_mapping-0.
|
58
|
+
math_spec_mapping-0.4.0.dist-info/LICENSE,sha256=ObyEzSw8kgCaFbEfpu1zP4TrcAKLA0xhqHMZZfyh7N0,1069
|
59
|
+
math_spec_mapping-0.4.0.dist-info/METADATA,sha256=nXVR7gQH2S2pfAhzZqFCa8dqRa1eB-dwXfzJt1peRFE,6849
|
60
|
+
math_spec_mapping-0.4.0.dist-info/WHEEL,sha256=A3WOREP4zgxI0fKrHUG8DC8013e3dK3n7a6HDbcEIwE,91
|
61
|
+
math_spec_mapping-0.4.0.dist-info/top_level.txt,sha256=AImhn9wgazkdV0a9vfiphtQR8uGe2nq-ZIOp-6yUk9o,18
|
62
|
+
math_spec_mapping-0.4.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|