From fcd2b29462c68c6bd97d5f8c7e351dd1067ce5f0 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Sat, 14 Oct 2023 18:51:30 -0400 Subject: [PATCH] Clean up adaptivity tests and some renaming (#67) * Clean up adaptivity tests * Rename long variables in micro_manager.py --- .github/workflows/run-adaptivity-test.yml | 2 +- micro_manager/micro_manager.py | 8 ++++---- tests/unit/test_adaptivity_serial.py | 18 ------------------ 3 files changed, 5 insertions(+), 23 deletions(-) diff --git a/.github/workflows/run-adaptivity-test.yml b/.github/workflows/run-adaptivity-test.yml index 1ffb3e61..e66dc318 100644 --- a/.github/workflows/run-adaptivity-test.yml +++ b/.github/workflows/run-adaptivity-test.yml @@ -1,4 +1,4 @@ -name: Test for functions in classes AdaptivityCalculator, LocalAdaptivityCalculator, GlobalAdaptivityCalculator +name: Test adaptivity functionality on: push: branches: diff --git a/micro_manager/micro_manager.py b/micro_manager/micro_manager.py index 452599b5..53340c79 100644 --- a/micro_manager/micro_manager.py +++ b/micro_manager/micro_manager.py @@ -116,7 +116,7 @@ def __init__(self, config_file: str) -> None: if name in self._write_data_names: self._adaptivity_micro_data_names[name] = is_data_vector - self._is_adaptivity_required_in_every_implicit_iteration = self._config.is_adaptivity_required_in_every_implicit_iteration() + self._adaptivity_in_every_implicit_step = self._config.is_adaptivity_required_in_every_implicit_iteration() self._micro_sims_active_steps = None # ************** @@ -282,7 +282,7 @@ def solve(self) -> None: n_checkpoint = n if self._is_adaptivity_on: - if not self._is_adaptivity_required_in_every_implicit_iteration: + if not self._adaptivity_in_every_implicit_step: similarity_dists, is_sim_active, sim_is_associated_to = self._adaptivity_controller.compute_adaptivity( self._dt, self._micro_sims, similarity_dists, is_sim_active, sim_is_associated_to, self._data_for_adaptivity) @@ -304,7 +304,7 @@ def solve(self) -> None: micro_sims_input = self._read_data_from_precice() if self._is_adaptivity_on: - if self._is_adaptivity_required_in_every_implicit_iteration: + if self._adaptivity_in_every_implicit_step: similarity_dists, is_sim_active, sim_is_associated_to = self._adaptivity_controller.compute_adaptivity( self._dt, self._micro_sims, similarity_dists, is_sim_active, sim_is_associated_to, self._data_for_adaptivity) @@ -339,7 +339,7 @@ def solve(self) -> None: # If adaptivity is computed only once per time window, the states of sims need to be reset too if self._is_adaptivity_on: - if not self._is_adaptivity_required_in_every_implicit_iteration: + if not self._adaptivity_in_every_implicit_step: similarity_dists = np.copy(similarity_dists_cp) is_sim_active = np.copy(is_sim_active_cp) sim_is_associated_to = np.copy(sim_is_associated_to_cp) diff --git a/tests/unit/test_adaptivity_serial.py b/tests/unit/test_adaptivity_serial.py index 9aaa7227..29ca8338 100644 --- a/tests/unit/test_adaptivity_serial.py +++ b/tests/unit/test_adaptivity_serial.py @@ -102,13 +102,6 @@ def test_update_active_sims(self): is_sim_active = np.array([True, True, True, True, True]) # Activate all micro sims before calling functionality - class MicroSimulation(): - pass - - dummy_micro_sims = [] - for _ in range(self._number_of_sims): - dummy_micro_sims.append(MicroSimulation()) - is_sim_active = adaptivity_controller._update_active_sims( self._similarity_dists, is_sim_active) @@ -153,17 +146,6 @@ def test_associate_active_to_inactive(self): is_sim_active = np.array([True, False, False, True, False]) expected_sim_is_associated_to = np.array([-2, 0, 0, -2, 3]) - class MicroSimulation(): - def __init__(self, global_id): - self._global_id = global_id - - def get_global_id(self): - return self._global_id - - dummy_micro_sims = [] - for i in range(self._number_of_sims): - dummy_micro_sims.append(MicroSimulation(i)) - sim_is_associated_to = np.array([-2, -2, -2, -2, -2]) sim_is_associated_to = adaptivity_controller._associate_inactive_to_active(