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

Sign up to get free protection for your applications and to get access to all the features.
@@ -477,17 +477,23 @@ class MathSpec:
477
477
  state_base,
478
478
  post_processing_function,
479
479
  state_preperation_functions=None,
480
+ parameter_preperation_functions=None,
480
481
  metrics_functions=None,
481
482
  ):
482
483
  if experiment["Param Modifications"]:
483
484
  params_base = deepcopy(params_base)
484
485
  for key in experiment["Param Modifications"]:
485
486
  params_base[key] = experiment["Param Modifications"][key]
487
+ if experiment["State Modifications"]:
488
+ state_base = deepcopy(state_base)
489
+ for key in experiment["State Modifications"]:
490
+ state_base[key] = experiment["State Modifications"][key]
486
491
  msi = self.build_implementation(params_base)
487
492
  state, params = msi.prepare_state_and_params(
488
493
  state_base,
489
494
  params_base,
490
495
  state_preperation_functions=state_preperation_functions,
496
+ parameter_preperation_functions=parameter_preperation_functions,
491
497
  )
492
498
 
493
499
  state = msi.execute_blocks(state, params, experiment["Blocks"])
@@ -510,6 +516,7 @@ class MathSpec:
510
516
  state_base,
511
517
  post_processing_function,
512
518
  state_preperation_functions=None,
519
+ parameter_preperation_functions=None,
513
520
  metrics_functions=None,
514
521
  ):
515
522
  state_l = []
@@ -524,6 +531,7 @@ class MathSpec:
524
531
  state_base,
525
532
  post_processing_function,
526
533
  state_preperation_functions=state_preperation_functions,
534
+ parameter_preperation_functions=parameter_preperation_functions,
527
535
  metrics_functions=metrics_functions,
528
536
  )
529
537
  df["Monte Carlo Run"] = i + 1
@@ -1007,7 +1015,13 @@ class MathSpecImplementation:
1007
1015
  len(shouldnt_be_in_params) == 0
1008
1016
  ), "The following parameters are extra: {}".format(shouldnt_be_in_params)
1009
1017
 
1010
- def prepare_state_and_params(self, state, params, state_preperation_functions=None):
1018
+ def prepare_state_and_params(
1019
+ self,
1020
+ state,
1021
+ params,
1022
+ state_preperation_functions=None,
1023
+ parameter_preperation_functions=None,
1024
+ ):
1011
1025
  self.validate_state_and_params(state, params)
1012
1026
  state = deepcopy(state)
1013
1027
  params = deepcopy(params)
@@ -1018,6 +1032,12 @@ class MathSpecImplementation:
1018
1032
  assert (
1019
1033
  state is not None
1020
1034
  ), "A state must be returned from the state preperation functions"
1035
+ if parameter_preperation_functions:
1036
+ for f in parameter_preperation_functions:
1037
+ params = f(params)
1038
+ assert (
1039
+ params is not None
1040
+ ), "A parameter set must be returned from the parameter preperation functions"
1021
1041
  return state, params
1022
1042
 
1023
1043
  def load_components(self):
@@ -39,19 +39,27 @@ def remove_dummy_repo_components(path):
39
39
  with open(path2 + "/__init__.py", "w") as f:
40
40
  f.write(contents)
41
41
 
42
- """if "Displays" in directory_folders:
42
+ if "Displays" in directory_folders:
43
43
  path2 = path + "/Displays"
44
44
  contents = os.listdir(path2)
45
- if "Dummy.py" in contents:
46
- os.remove(path2 + "/Dummy.py")
47
- if "__init__.py" in contents:
48
- with open(path2 + "/__init__.py", "r") as f:
45
+ if "wiring.py" in contents:
46
+ with open(path2 + "/wiring.py", "r") as f:
49
47
  contents = f.read()
50
- contents = contents.replace("from .Dummy import metrics_x\n", "")
51
- contents = contents.replace("metrics.extend(metrics_x)\n", "")
52
- contents = contents.replace("metrics.extend(metrics_x)", "")
53
- with open(path2 + "/__init__.py", "w") as f:
54
- f.write(contents)"""
48
+
49
+ contents = contents.replace('"Dummy Boundary Wiring 2",\n', "")
50
+ contents = contents.replace('"Dummy Boundary Wiring 2",', "")
51
+ contents = contents.replace('"Dummy Boundary Wiring 2"', "")
52
+
53
+ contents = contents.replace('"Dummy Boundary Wiring",\n', "")
54
+ contents = contents.replace('"Dummy Boundary Wiring",', "")
55
+ contents = contents.replace('"Dummy Boundary Wiring"', "")
56
+
57
+ contents = contents.replace('"Dummy Control Wiring",\n', "")
58
+ contents = contents.replace('"Dummy Control Wiring",', "")
59
+ contents = contents.replace('"Dummy Control Wiring"', "")
60
+
61
+ with open(path2 + "/wiring.py", "w") as f:
62
+ f.write(contents)
55
63
 
56
64
  if "Wiring" in directory_folders:
57
65
  path2 = path + "/Wiring"
@@ -104,8 +112,14 @@ def remove_dummy_repo_components(path):
104
112
  with open(path2 + "/__init__.py", "r") as f:
105
113
  contents = f.read()
106
114
  contents = contents.replace(
107
- "from .Dummy import dummy_boundary_action\n", ""
115
+ "from .Dummy import dummy_boundary_action, dummy_boundary_action2\n",
116
+ "",
108
117
  )
118
+
119
+ contents = contents.replace("dummy_boundary_action2,\n", "")
120
+ contents = contents.replace("dummy_boundary_action2,", "")
121
+ contents = contents.replace("dummy_boundary_action2", "")
122
+
109
123
  contents = contents.replace("dummy_boundary_action,\n", "")
110
124
  contents = contents.replace("dummy_boundary_action,", "")
111
125
  contents = contents.replace("dummy_boundary_action", "")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: math-spec-mapping
3
- Version: 0.3.7
3
+ Version: 0.3.8
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,7 +6,7 @@ math_spec_mapping/Classes/Block.py,sha256=cGtIhNgRfoDZ0O3SxeXcNzNlHcdXIB89sT2uaZ
6
6
  math_spec_mapping/Classes/BoundaryAction.py,sha256=KuZqtvZwSHWDP7gFQXGnG-r3EuYJU_oU9wMCuqvRkzk,593
7
7
  math_spec_mapping/Classes/ControlAction.py,sha256=ysqpgANwdizVdwqtgZmnxXMpCqrzmVEF_6YT0M3l4Ho,526
8
8
  math_spec_mapping/Classes/Entity.py,sha256=fA0-b128_OHHxfCg4pzqyQV083EYev1HlVpy86S5igg,1226
9
- math_spec_mapping/Classes/MathSpec.py,sha256=YopqG_ca7nxgPPZxQR9b442C155ZJGfs73CDEIL5uMc,39038
9
+ math_spec_mapping/Classes/MathSpec.py,sha256=6cBpp9OHmfU-XTqPI4Qjnj91cXRxfGtcAQnczOKxt-4,39892
10
10
  math_spec_mapping/Classes/Mechanism.py,sha256=2sLm3wYBIeTQaMBcsJ9btqIWsbS895Ra8NY6Y9_G_Dg,379
11
11
  math_spec_mapping/Classes/Metric.py,sha256=AhPgYppOP6q49xvR8S9STxQsXUKJlTWx7wI1LfZEtww,581
12
12
  math_spec_mapping/Classes/Parameter.py,sha256=ZuJ_w0sChvRElJ4sOnXZ2EV4Ell2xXFulKLjVOpgz2E,1237
@@ -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=Pv0b5pHnv5Bxk3PkY8O9Nv62z2C_gxj5xcf8G9r4Pkw,11010
22
+ math_spec_mapping/Convenience/starter.py,sha256=vflOgTVRvM5OMBB7kHnoLR-sGeukKxOJNJmJzQm9Ick,11649
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
@@ -53,8 +53,8 @@ math_spec_mapping/Reports/spaces.py,sha256=-76hR5wQBv4lsG000ypBJ-OprjsNjI-rNRMYd
53
53
  math_spec_mapping/Reports/state.py,sha256=RkqfSonar74KVC8PpA9GgI2xaHX6BrkNdAuWMZlYQfI,2321
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.7.dist-info/LICENSE,sha256=ObyEzSw8kgCaFbEfpu1zP4TrcAKLA0xhqHMZZfyh7N0,1069
57
- math_spec_mapping-0.3.7.dist-info/METADATA,sha256=Y4GIicxIeBa44LDgCxCdNAedQ7EZunZn-VD3JPMfFF4,6500
58
- math_spec_mapping-0.3.7.dist-info/WHEEL,sha256=mguMlWGMX-VHnMpKOjjQidIo1ssRlCFu4a4mBpz1s2M,91
59
- math_spec_mapping-0.3.7.dist-info/top_level.txt,sha256=AImhn9wgazkdV0a9vfiphtQR8uGe2nq-ZIOp-6yUk9o,18
60
- math_spec_mapping-0.3.7.dist-info/RECORD,,
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,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (70.1.1)
2
+ Generator: setuptools (70.2.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5