Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
IshaanDesai committed Dec 16, 2024
1 parent c716df8 commit 283539c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
12 changes: 7 additions & 5 deletions tests/unit/test_adaptivity_serial.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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 = [
Expand All @@ -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(
Expand Down Expand Up @@ -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 = [
Expand All @@ -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 = [
Expand Down
15 changes: 8 additions & 7 deletions tests/unit/test_micro_simulation_crash_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 283539c

Please sign in to comment.