From efd77925941a1b7274ecdea767630b556623f2c7 Mon Sep 17 00:00:00 2001 From: Will Wolf Date: Fri, 21 Jan 2022 09:59:11 -0500 Subject: [PATCH 1/2] treat sweep_dicts as list of dicts, zip over this object in partial_state_update --- cadCAD/engine/simulation.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cadCAD/engine/simulation.py b/cadCAD/engine/simulation.py index cb492706..8cc72a6a 100644 --- a/cadCAD/engine/simulation.py +++ b/cadCAD/engine/simulation.py @@ -149,7 +149,7 @@ def transfer_missing_fields(source, destination): # mech_pipeline - state_update_block def state_update_pipeline( self, - sweep_dict: Dict[str, List[Any]], + sweep_dicts: List[Dict[str, Any]], simulation_list, configs: List[Tuple[List[Callable], List[Callable]]], env_processes: Dict[str, Callable], @@ -170,7 +170,7 @@ def state_update_pipeline( states_list: List[Dict[str, Any]] = [genesis_states] sub_step += 1 - for [s_conf, p_conf] in configs: + for [s_conf, p_conf], sweep_dict in zip(configs, sweep_dicts): states_list: List[Dict[str, Any]] = self.partial_state_update( sweep_dict, sub_step, states_list, simulation_list, s_conf, p_conf, env_processes, time_step, run, additional_objs @@ -184,7 +184,7 @@ def state_update_pipeline( # state_update_pipeline def run_pipeline( self, - sweep_dict: Dict[str, List[Any]], + sweep_dicts: List[Dict[str, Any]], states_list: List[Dict[str, Any]], configs: List[Tuple[List[Callable], List[Callable]]], env_processes: Dict[str, Callable], @@ -197,7 +197,7 @@ def run_pipeline( for time_step in time_seq: pipe_run: List[Dict[str, Any]] = self.state_update_pipeline( - sweep_dict, simulation_list, configs, env_processes, time_step, run, additional_objs + sweep_dicts, simulation_list, configs, env_processes, time_step, run, additional_objs ) _, *pipe_run = pipe_run simulation_list.append(pipe_run) @@ -206,7 +206,7 @@ def run_pipeline( def simulation( self, - sweep_dict: Dict[str, List[Any]], + sweep_dicts: List[Dict[str, Any]], states_list: List[Dict[str, Any]], configs, env_processes: Dict[str, Callable], @@ -222,7 +222,7 @@ def simulation( run += 1 subset_window.appendleft(subset_id) - def execute_run(sweep_dict, states_list, configs, env_processes, time_seq, _run) -> List[Dict[str, Any]]: + def execute_run(sweep_dicts, states_list, configs, env_processes, time_seq, _run) -> List[Dict[str, Any]]: def generate_init_sys_metrics(genesis_states_list, sim_id, _subset_id, _run, _subset_window): for D in genesis_states_list: d = deepcopy(D) @@ -235,14 +235,14 @@ def generate_init_sys_metrics(genesis_states_list, sim_id, _subset_id, _run, _su ) first_timestep_per_run: List[Dict[str, Any]] = self.run_pipeline( - sweep_dict, states_list_copy, configs, env_processes, time_seq, run, additional_objs + sweep_dicts, states_list_copy, configs, env_processes, time_seq, run, additional_objs ) del states_list_copy return first_timestep_per_run pipe_run = flatten( - [execute_run(sweep_dict, states_list, configs, env_processes, time_seq, run)] + [execute_run(sweep_dicts, states_list, configs, env_processes, time_seq, run)] ) return pipe_run From 1a988d516b8f1915b8354a9c6ffaa8011a159ec2 Mon Sep 17 00:00:00 2001 From: Will Wolf Date: Fri, 21 Jan 2022 12:48:34 -0500 Subject: [PATCH 2/2] update sweep_dict parameter type --- cadCAD/engine/simulation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cadCAD/engine/simulation.py b/cadCAD/engine/simulation.py index 8cc72a6a..68a6c2c7 100644 --- a/cadCAD/engine/simulation.py +++ b/cadCAD/engine/simulation.py @@ -102,7 +102,7 @@ def env_composition(target_field, state_dict, target_value): # mech_step def partial_state_update( self, - sweep_dict: Dict[str, List[Any]], + sweep_dict: Dict[str, Any], sub_step: int, sL, sH,