math-spec-mapping 0.4.1__py3-none-any.whl → 0.4.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1041,10 +1041,25 @@ using .Spaces: generate_space_type
1041
1041
  blocks,
1042
1042
  state_preperation_functions=[],
1043
1043
  parameter_preperation_functions=[],
1044
+ fixed_parameters=None,
1045
+ fixed_state=None,
1044
1046
  ):
1045
1047
  out = {}
1046
1048
  out["StateSpace"] = self._build_state_space()
1049
+ if fixed_state:
1050
+ for key in fixed_state:
1051
+ assert (
1052
+ key in out["StateSpace"]
1053
+ ), "The fixed parameter {} is not in the state space".format(key)
1054
+ out["StateSpace"].pop(key)
1055
+
1047
1056
  out["ParameterSpace"] = self._build_parameter_space()
1057
+ if fixed_parameters:
1058
+ for key in fixed_parameters:
1059
+ assert (
1060
+ key in out["ParameterSpace"]
1061
+ ), "The fixed parameter {} is not in the parameter space".format(key)
1062
+ out["ParameterSpace"].pop(key)
1048
1063
  out["Model"] = cadCADModel(
1049
1064
  self,
1050
1065
  out["StateSpace"],
@@ -1052,6 +1067,8 @@ using .Spaces: generate_space_type
1052
1067
  blocks,
1053
1068
  state_preperation_functions=state_preperation_functions,
1054
1069
  parameter_preperation_functions=parameter_preperation_functions,
1070
+ fixed_parameters=fixed_parameters,
1071
+ fixed_state=fixed_state,
1055
1072
  )
1056
1073
  return out
1057
1074
 
@@ -1079,6 +1096,8 @@ class cadCADModel:
1079
1096
  blocks,
1080
1097
  state_preperation_functions=[],
1081
1098
  parameter_preperation_functions=[],
1099
+ fixed_parameters=None,
1100
+ fixed_state=None,
1082
1101
  ):
1083
1102
  self.ms = ms
1084
1103
  self.state_space = state_space
@@ -1086,10 +1105,18 @@ class cadCADModel:
1086
1105
  self.blocks = blocks
1087
1106
  self.state_preperation_functions = state_preperation_functions
1088
1107
  self.parameter_preperation_functions = parameter_preperation_functions
1108
+ self.fixed_parameters = fixed_parameters
1109
+ self.fixed_state = fixed_state
1089
1110
 
1090
1111
  def create_experiment(
1091
1112
  self, state, params, record_trajectory=False, use_deepcopy=True
1092
1113
  ):
1114
+ if self.fixed_state:
1115
+ for x in self.fixed_state:
1116
+ state[x] = self.fixed_state[x]
1117
+ if self.fixed_parameters:
1118
+ for x in self.fixed_parameters:
1119
+ params[x] = self.fixed_parameters[x]
1093
1120
  return Experiment(
1094
1121
  self,
1095
1122
  state,
@@ -1180,11 +1207,11 @@ class BatchExperiments:
1180
1207
  def step(self):
1181
1208
  for experiment in self.experiments:
1182
1209
  experiment.step()
1183
-
1210
+
1184
1211
  def run(self, t):
1185
1212
  for experiment in self.experiments:
1186
1213
  experiment.run(t)
1187
-
1214
+
1188
1215
  @property
1189
1216
  def trajectories(self):
1190
1217
  return [experiment.trajectories for experiment in self.experiments]
@@ -6,3 +6,4 @@ from .github import (
6
6
  create_priority_label_matrix,
7
7
  create_milestone_label_matrix,
8
8
  )
9
+ from .cadCAD import get_nested_types
@@ -0,0 +1,21 @@
1
+ from copy import deepcopy
2
+ from typing import _TypedDictMeta, _GenericAlias
3
+
4
+
5
+ def get_underlying_type(data):
6
+ if type(data) == _GenericAlias:
7
+ data = [get_underlying_type(x) for x in data.__args__]
8
+ elif type(data) == _TypedDictMeta:
9
+ data = get_nested_types(data.__annotations__)
10
+ return data
11
+
12
+
13
+ def get_nested_types(data):
14
+ data = deepcopy(data)
15
+ for key in data:
16
+ if type(data[key]) == _TypedDictMeta:
17
+ data[key] = get_nested_types(data[key].__annotations__)
18
+ elif type(data[key]) == _GenericAlias:
19
+ data[key] = get_underlying_type(data[key])
20
+
21
+ return data
@@ -86,4 +86,8 @@ def load_from_json(json: Dict, spec_path=None) -> MathSpec:
86
86
  if spec_path:
87
87
  tree = load_spec_tree(spec_path, ms)
88
88
  ms._add_spec_tree(tree)
89
+ else:
90
+ print(
91
+ "Add spec path to load_from_json to load spec tree and allow linking to the code in Obsidian"
92
+ )
89
93
  return ms
@@ -70,7 +70,10 @@ def write_source_code_block(component, text, path):
70
70
  if hasattr(component, "source_code_location"):
71
71
  file_path = component.source_code_location
72
72
  else:
73
- file_path = component["Source Code Location"]
73
+ try:
74
+ file_path = component["Source Code Location"]
75
+ except:
76
+ file_path = None
74
77
  if file_path:
75
78
  file_path = os.path.relpath(file_path, path)
76
79
  text += "## Spec Source Code Location\n\n"
@@ -36,6 +36,7 @@ from .Convenience import (
36
36
  find_open_issues,
37
37
  create_priority_label_matrix,
38
38
  create_milestone_label_matrix,
39
+ get_nested_types,
39
40
  )
40
41
 
41
42
  # from .Convenience import write_top_level_json_description
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: math-spec-mapping
3
- Version: 0.4.1
3
+ Version: 0.4.2
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
@@ -14,7 +14,6 @@ Requires-Dist: ipython>=7.7.0
14
14
  Requires-Dist: pandas>=1.4
15
15
  Requires-Dist: jsonschema>=4.21.1
16
16
  Requires-Dist: PyGithub==2.5.0
17
- Requires-Dist: dotenv
18
17
  Requires-Dist: python-dotenv>=1.0.0
19
18
 
20
19
  # Mathematical Specification Mapping Library (MSML)
@@ -31,7 +30,7 @@ One good example is the [wiring report](https://github.com/BlockScience/Predator
31
30
 
32
31
  ## Installing the library
33
32
 
34
- To install the library, simply pip install by running "pip install math_spec_mapping"
33
+ To install the library, simply pip install by running "pip install math-spec-mapping". The pypi package can be found [here](https://pypi.org/project/math-spec-mapping/).
35
34
 
36
35
  ## Why MSML?
37
36
 
@@ -1,4 +1,4 @@
1
- math_spec_mapping/__init__.py,sha256=7fGuxoSDYl61z0PZ_PzS6x5P8l174gOzobI9u0aoLVw,1260
1
+ math_spec_mapping/__init__.py,sha256=-w5j-DhqAUF9vI7k8SlqMiq39MeATebE6MCw5F2ozk4,1282
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
@@ -6,7 +6,7 @@ math_spec_mapping/Classes/Block.py,sha256=2VOBTPRafmtaLY847tEw3OJTrWNp2d0aSStC_u
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=rXiAWuIxtdo4myvCNq7qkBPycCGErMQzVvBRq97HrJc,64548
9
+ math_spec_mapping/Classes/MathSpec.py,sha256=i6-iWj7SnGWjqwWxiwZ0ysiiNPGHGsidCEgK1KMgumc,65605
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
@@ -17,7 +17,8 @@ math_spec_mapping/Classes/StateUpdateTransmissionChannel.py,sha256=3hBLvD1lE64Pk
17
17
  math_spec_mapping/Classes/StatefulMetric.py,sha256=plMFMAFEk1y2t4DR5lA2SRC9UrYArsx_W33l3mZSdgE,804
18
18
  math_spec_mapping/Classes/Type.py,sha256=cA5-5nOfjX6aHzTHM8M6mP5lsS7foumckRu7WDX610M,339
19
19
  math_spec_mapping/Classes/__init__.py,sha256=0zxgOqns_9JybD74HKMVh6aw8ij8WVbfQ4Q_1uWzof0,761
20
- math_spec_mapping/Convenience/__init__.py,sha256=BEZr1rXohKAknOa3wjNVx3EvSVxDcfftJsvtSw5mvmQ,264
20
+ math_spec_mapping/Convenience/__init__.py,sha256=shG4kNPw3z9sSqHmRTLmqvUKMkK1Rq_9XNer2HIWZ9A,301
21
+ math_spec_mapping/Convenience/cadCAD.py,sha256=t-d9FEvfcnjX326eMoCxV6eyE3qVqB0HldDNrrcYquQ,626
21
22
  math_spec_mapping/Convenience/documentation.py,sha256=1ziWVJznbCUxeAAt03nAdEYtMlXNo5TeedHfgs0vSBU,1625
22
23
  math_spec_mapping/Convenience/github.py,sha256=JMFJWyA3nRIMNYGvn9831BolnBthoa48HhgeZuENZm8,3772
23
24
  math_spec_mapping/Convenience/starter.py,sha256=dD1R9wcVFZV-BCTflxNkR6Ay6NF1TlVBdIaWmbJwMGE,17379
@@ -29,7 +30,7 @@ math_spec_mapping/Load/displays.py,sha256=uQvs0Jhp8-9SXGex8SG3ibxHJu7ahAV3xLeBFb
29
30
  math_spec_mapping/Load/entities.py,sha256=Ds7VQY_govWEn1vSHYVrLa8IadSNyOQzaCK18JPYPKk,1289
30
31
  math_spec_mapping/Load/general.py,sha256=Wjg0ESB80j9UwvoRB_-J8SBKq3KqCFZAKsuKNJFqkE4,4789
31
32
  math_spec_mapping/Load/implementations.py,sha256=a8YvumnyQvrnCo-o52Rv4yU8D7nmkMrV1iIA15fr6Bw,490
32
- math_spec_mapping/Load/load.py,sha256=Cm1IP_jIzWNGFVPcb1OOfQQYSNgyIfUdT--v1D1dkKE,2797
33
+ math_spec_mapping/Load/load.py,sha256=65O8FlLbze5b8WDhbAMHF3B48IfcNijeX4k-WeEy864,2938
33
34
  math_spec_mapping/Load/mechanism.py,sha256=6tgISsxc-SXCYS5yxuIqnl0nX__t1k0uj9z0O0E1uC4,2367
34
35
  math_spec_mapping/Load/metrics.py,sha256=CcVM0_aN-aPnH5_AyEKzFCJGPbgMb0brw5nECsdNVeU,3936
35
36
  math_spec_mapping/Load/parameters.py,sha256=W4utm7to3s2fo4z3XgLH0TM1agaIad1qfM2I-lLMua4,1393
@@ -46,7 +47,7 @@ math_spec_mapping/Reports/boundary_actions.py,sha256=45BPp4QjWdD-3E9ZWwqgj_nI2-Y
46
47
  math_spec_mapping/Reports/control_actions.py,sha256=NksekZKIPFSIkubttFstKFthc5AU9B9PWRLSl9j1wWs,1216
47
48
  math_spec_mapping/Reports/general.py,sha256=WOOn6Wlb8M4fsdN49FlKLwOka6vJPQ9aCUy88TL2ki0,1610
48
49
  math_spec_mapping/Reports/html.py,sha256=MCVp_D1LuRoZrHtwzFOJGQviztGeahqsWf3Zue1Yz64,10134
49
- math_spec_mapping/Reports/markdown.py,sha256=q4dCzH6dDE0TLJ3XS7olUpDfPk8323IEPbT9ki7GEgE,30595
50
+ math_spec_mapping/Reports/markdown.py,sha256=2WYZYzIubtNb-OyZCOK5nS_O9jPOsdwAtMMJJOt-ZDk,30657
50
51
  math_spec_mapping/Reports/mechanisms.py,sha256=d2Rxt3JBYvqAOAYUynl0buYVoXEHrO8EGq7GK6hK8NA,1322
51
52
  math_spec_mapping/Reports/node_map.py,sha256=FdSMDQG16NX6n9sZcH-T5xwsvgjrV9OqBHc9J_VlNK0,3129
52
53
  math_spec_mapping/Reports/parameters.py,sha256=-ucL71lolqU0xvV7yb0sXl4pFMRl5tXNWdoBfUjLOaQ,1944
@@ -55,8 +56,8 @@ math_spec_mapping/Reports/spaces.py,sha256=-76hR5wQBv4lsG000ypBJ-OprjsNjI-rNRMYd
55
56
  math_spec_mapping/Reports/state.py,sha256=QYeCvX5cHeZBrbvMeDsTqJcUDTuDFJSLvPbasjLspk8,3643
56
57
  math_spec_mapping/Reports/tables.py,sha256=O0CNuqh3LMECq5uLjBOoxMUk5hUvkUK660FNnwWUxDY,1505
57
58
  math_spec_mapping/Reports/wiring.py,sha256=u9SvKWy6T-WJUEgFI6-zgZanoOaTTs_2YwmEceDLsV8,1618
58
- math_spec_mapping-0.4.1.dist-info/LICENSE,sha256=ObyEzSw8kgCaFbEfpu1zP4TrcAKLA0xhqHMZZfyh7N0,1069
59
- math_spec_mapping-0.4.1.dist-info/METADATA,sha256=UqNOOafGIeJY_gp-mgFXNK2TF6lE_dR8TI-GKGy3i4g,6972
60
- math_spec_mapping-0.4.1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
61
- math_spec_mapping-0.4.1.dist-info/top_level.txt,sha256=AImhn9wgazkdV0a9vfiphtQR8uGe2nq-ZIOp-6yUk9o,18
62
- math_spec_mapping-0.4.1.dist-info/RECORD,,
59
+ math_spec_mapping-0.4.2.dist-info/LICENSE,sha256=ObyEzSw8kgCaFbEfpu1zP4TrcAKLA0xhqHMZZfyh7N0,1069
60
+ math_spec_mapping-0.4.2.dist-info/METADATA,sha256=_JU9rnSp9fWd55xL0_1g3NozwwWuG3hhYABqrr0IDmU,7034
61
+ math_spec_mapping-0.4.2.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
62
+ math_spec_mapping-0.4.2.dist-info/top_level.txt,sha256=AImhn9wgazkdV0a9vfiphtQR8uGe2nq-ZIOp-6yUk9o,18
63
+ math_spec_mapping-0.4.2.dist-info/RECORD,,