diff --git a/micro_manager/adaptivity/global_adaptivity.py b/micro_manager/adaptivity/global_adaptivity.py index 872be91..6489336 100644 --- a/micro_manager/adaptivity/global_adaptivity.py +++ b/micro_manager/adaptivity/global_adaptivity.py @@ -269,7 +269,9 @@ def _update_inactive_sims( ), "MicroSimulation", ) - micro_sims[to_be_activated_local_id] = create_simulation_class(micro_problem)(i) + micro_sims[to_be_activated_local_id] = create_simulation_class( + micro_problem + )(i) self._logger.info(f"lazy initialization of {i} successful") assoc_active_id = local_sim_is_associated_to[to_be_activated_local_id] diff --git a/micro_manager/adaptivity/local_adaptivity.py b/micro_manager/adaptivity/local_adaptivity.py index ad3f2fe..35da969 100644 --- a/micro_manager/adaptivity/local_adaptivity.py +++ b/micro_manager/adaptivity/local_adaptivity.py @@ -137,8 +137,8 @@ def _update_inactive_sims( micro_problem = getattr( importlib.import_module( self._micro_file_name, "MicroSimulation" - ), - "MicroSimulation", + ), + "MicroSimulation", ) micro_sims[i] = create_simulation_class(micro_problem)(i) self._logger.info(f"lazy initalization of {i} successful") diff --git a/micro_manager/config.py b/micro_manager/config.py index decd952..108b661 100644 --- a/micro_manager/config.py +++ b/micro_manager/config.py @@ -185,7 +185,10 @@ def read_json_micro_manager(self): else: raise Exception("Adaptivity type can be either local or global.") - if self._data["simulation_params"]["adaptivity_settings"].get("lazy_init") == "True": + if ( + self._data["simulation_params"]["adaptivity_settings"].get("lazy_init") + == "True" + ): self._micro_sims_lazy_init = True exchange_data = {**self._read_data_names, **self._write_data_names} diff --git a/micro_manager/micro_manager.py b/micro_manager/micro_manager.py index 7895481..8f0c63e 100644 --- a/micro_manager/micro_manager.py +++ b/micro_manager/micro_manager.py @@ -80,7 +80,9 @@ def __init__(self, config_file: str) -> None: self._is_adaptivity_on = self._config.turn_on_adaptivity() - self._micro_sims_lazy_init = self._is_adaptivity_on and self._config.micro_sims_lazy_init() + self._micro_sims_lazy_init = ( + self._is_adaptivity_on and self._config.micro_sims_lazy_init() + ) if self._is_adaptivity_on: self._number_of_sims_for_adaptivity = 0 @@ -187,7 +189,9 @@ def solve(self) -> None: # Write a checkpoint if self._participant.requires_writing_checkpoint(): for i in range(self._local_number_of_sims): - sim_states_cp[i] = self._micro_sims[i].get_state() if self._micro_sims[i] else None + sim_states_cp[i] = ( + self._micro_sims[i].get_state() if self._micro_sims[i] else None + ) t_checkpoint = t n_checkpoint = n @@ -259,8 +263,12 @@ def solve(self) -> None: for active_id in active_sim_ids: self._micro_sims_active_steps[active_id] += 1 if sim_states_cp[active_id] == None: - sim_states_cp[active_id] = self._micro_sims[active_id].get_state() - self._logger.info(f"state of lazily initialized micro sim {self._global_ids_of_local_sims[active_id]} successfully checkpointed") + sim_states_cp[active_id] = self._micro_sims[ + active_id + ].get_state() + self._logger.info( + f"state of lazily initialized micro sim {self._global_ids_of_local_sims[active_id]} successfully checkpointed" + ) micro_sims_output = self._solve_micro_simulations_with_adaptivity( micro_sims_input, is_sim_active, sim_is_associated_to, dt @@ -442,7 +450,8 @@ def initialize(self) -> None: ) self._logger.info( "Micro simulations with global IDs {} - {} created.".format( - self._global_ids_of_local_sims[0], self._global_ids_of_local_sims[-1] + self._global_ids_of_local_sims[0], + self._global_ids_of_local_sims[-1], ) ) @@ -473,7 +482,9 @@ def initialize(self) -> None: if not initial_data: is_initial_data_available = False if self._micro_sims_lazy_init: - raise Exception("no initial macro data available, lazy initialization would result in only one active simulation.") + raise Exception( + "no initial macro data available, lazy initialization would result in only one active simulation." + ) else: is_initial_data_available = True @@ -485,7 +496,9 @@ def initialize(self) -> None: getattr(micro_problem, "initialize") ): if self._micro_sims_lazy_init: - raise Exception("Adaptivity can't use data returned by initialize function of micro sims when using lazy initialization.") + raise Exception( + "Adaptivity can't use data returned by initialize function of micro sims when using lazy initialization." + ) self._micro_sims_init = True # Starting value before setting try: # Try to get the signature of the initialize() method, if it is written in Python