From 283539c95d99cde1061acda4a544737557d74a30 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Mon, 16 Dec 2024 18:30:13 +0100 Subject: [PATCH] Fix tests --- tests/unit/test_adaptivity_serial.py | 12 +++++++----- .../unit/test_micro_simulation_crash_handling.py | 15 ++++++++------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/tests/unit/test_adaptivity_serial.py b/tests/unit/test_adaptivity_serial.py index e2ac83d..de9e71b 100644 --- a/tests/unit/test_adaptivity_serial.py +++ b/tests/unit/test_adaptivity_serial.py @@ -68,7 +68,7 @@ def test_get_similarity_dists(self): """ configurator = MagicMock() configurator.get_adaptivity_similarity_measure = MagicMock(return_value="L1") - adaptivity_controller = AdaptivityCalculator(configurator) + adaptivity_controller = AdaptivityCalculator(configurator, 0) adaptivity_controller._hist_param = 0.5 adaptivity_controller._adaptivity_data_names = [ "micro-scalar-data", @@ -102,7 +102,7 @@ def test_update_active_sims(self): """ configurator = MagicMock() configurator.get_adaptivity_similarity_measure = MagicMock(return_value="L1") - adaptivity_controller = AdaptivityCalculator(configurator) + adaptivity_controller = AdaptivityCalculator(configurator, 0) adaptivity_controller._refine_const = self._refine_const adaptivity_controller._coarse_const = self._coarse_const adaptivity_controller._adaptivity_data_names = [ @@ -127,7 +127,7 @@ def test_adaptivity_norms(self): """ Test functionality for calculating similarity criteria between pairs of simulations using different norms in class AdaptivityCalculator. """ - calc = AdaptivityCalculator(Config("micro-manager-config.json")) + calc = AdaptivityCalculator(Config("micro-manager-config.json"), 0) fake_data = np.array([[1], [2], [3]]) self.assertTrue( @@ -208,7 +208,7 @@ def test_associate_active_to_inactive(self): """ configurator = MagicMock() configurator.get_adaptivity_similarity_measure = MagicMock(return_value="L1") - adaptivity_controller = AdaptivityCalculator(configurator) + adaptivity_controller = AdaptivityCalculator(configurator, 0) adaptivity_controller._refine_const = self._refine_const adaptivity_controller._coarse_const = self._coarse_const adaptivity_controller._adaptivity_data_names = [ @@ -235,7 +235,9 @@ def test_update_inactive_sims_local_adaptivity(self): """ configurator = MagicMock() configurator.get_adaptivity_similarity_measure = MagicMock(return_value="L1") - adaptivity_controller = LocalAdaptivityCalculator(configurator, MagicMock()) + adaptivity_controller = LocalAdaptivityCalculator( + configurator, 0, MagicMock(), 5 + ) adaptivity_controller._refine_const = self._refine_const adaptivity_controller._coarse_const = self._coarse_const adaptivity_controller._adaptivity_data_names = [ diff --git a/tests/unit/test_micro_simulation_crash_handling.py b/tests/unit/test_micro_simulation_crash_handling.py index 8e74479..0cdbf9f 100644 --- a/tests/unit/test_micro_simulation_crash_handling.py +++ b/tests/unit/test_micro_simulation_crash_handling.py @@ -98,15 +98,16 @@ def test_crash_handling_with_adaptivity(self): ) manager._micro_sims = [MicroSimulation(i) for i in range(5)] - adaptivity_data = [] - adaptivity_data.append(np.array([0, 0, 0, 0, 0])) # similarity_dists - adaptivity_data.append( - np.array([True, True, True, True, False]) - ) # is_sim_active - adaptivity_data.append(np.array([-2, -2, -2, -2, 2])) # sim_is_associated_to + manager._adaptivity_controller._similarity_dists = np.array([0, 0, 0, 0, 0]) + manager._adaptivity_controller._is_sim_active = np.array( + [True, True, True, True, False] + ) + manager._adaptivity_controller._sim_is_associated_to = np.array( + [-2, -2, -2, -2, 2] + ) micro_sims_output = manager._solve_micro_simulations_with_adaptivity( - macro_data, 1.0, adaptivity_data + macro_data, 1.0 ) # Crashed simulation has interpolated value