From 9e809d545767d51f745838d4005446ab212fe85b Mon Sep 17 00:00:00 2001 From: Logan Drescher Date: Mon, 18 Nov 2024 10:07:39 -0500 Subject: [PATCH] Updating framework to prevent fall-through terms on algorithms --- biosimulators_copasi/core.py | 2 +- biosimulators_copasi/data_model.py | 314 +++++++++++++++++++++-------- biosimulators_copasi/utils.py | 4 +- tests/test_core.py | 5 +- tests/test_utils.py | 39 ++-- 5 files changed, 259 insertions(+), 105 deletions(-) diff --git a/biosimulators_copasi/core.py b/biosimulators_copasi/core.py index d280394..90dc4a2 100644 --- a/biosimulators_copasi/core.py +++ b/biosimulators_copasi/core.py @@ -421,7 +421,7 @@ def _load_algorithm_parameters(sim: Simulation, copasi_algorithm: utils.CopasiAl # Load the algorithm parameter changes specified by `simulation.algorithm_parameter_changes` algorithm_substitution_policy: AlgSubPolicy = bsu_sim_utils.get_algorithm_substitution_policy(config=config) requested_algorithm: Algorithm = sim.algorithm - if copasi_algorithm.KISAO_ID != requested_algorithm.kisao_id: + if copasi_algorithm.get_kisao_id() != requested_algorithm.kisao_id: return unsupported_parameters, bad_parameters = utils.set_algorithm_parameter_values(copasi_algorithm, diff --git a/biosimulators_copasi/data_model.py b/biosimulators_copasi/data_model.py index 435ab5c..aeb72fd 100644 --- a/biosimulators_copasi/data_model.py +++ b/biosimulators_copasi/data_model.py @@ -614,10 +614,6 @@ def set_value(self, new_value: list): class CopasiAlgorithm: - KISAO_ID: str - ID: CopasiAlgorithmType - NAME: str - CAN_SUPPORT_EVENTS: bool def get_parameters_by_kisao(self) -> dict[str, CopasiAlgorithmParameter]: return { @@ -626,7 +622,8 @@ def get_parameters_by_kisao(self) -> dict[str, CopasiAlgorithmParameter]: if isinstance(getattr(self, member), CopasiAlgorithmParameter) } - def get_copasi_id(self) -> str: + @staticmethod + def get_copasi_id() -> str: raise NotImplementedError def get_unit_set(self) -> Units: @@ -635,26 +632,36 @@ def get_unit_set(self) -> Units: def get_overrides(self) -> dict: raise NotImplementedError + @staticmethod + def get_kisao_id() -> str: + return None + + @staticmethod + def get_name() -> str: + return "Enhanced Newton" + + @staticmethod + def can_support_events(): + return False + def get_method_settings(self) -> dict[str, str]: - settings: dict[str, str] = {"name": self.NAME} - settings.update(self.get_overrides()) + settings: dict[str, str] = {"name": self.get_name()} + additional_settings = self.get_overrides() + for key, value in additional_settings.items(): + settings[key] = value return settings def __eq__(self, other): if not isinstance(other, type(self)): return False - kisao_equality = self.KISAO_ID == other.KISAO_ID - id_equality = self.ID == other.ID - name_equality = self.NAME == other.NAME - event_support_equality = self.CAN_SUPPORT_EVENTS == other.CAN_SUPPORT_EVENTS + kisao_equality = self.get_kisao_id() == other.get_kisao_id() + id_equality = self.get_copasi_id() == other.get_copasi_id() + name_equality = self.get_name() == other.get_name() + event_support_equality = self.can_support_events() == other.can_support_events() return kisao_equality and id_equality and name_equality and event_support_equality class SteadyStateAlgorithm(CopasiAlgorithm): - KISAO_ID: str = None - ID: str = None - NAME: str = "Enhanced Newton" - CAN_SUPPORT_EVENTS: bool = False def __init__(self, use_newton: bool, use_integration: bool, use_back_integration: bool = False, resolution: float = 1e-09, derivation_factor: float = 0.001, @@ -696,10 +703,20 @@ def get_overrides(self) -> dict: overrides.update(self.target_criterion.get_override_repr()) return overrides + @staticmethod + def get_kisao_id() -> str: + return None + + @staticmethod + def get_name() -> str: + return "Enhanced Newton" + + @staticmethod + def can_support_events(): + return False + class CopasiHybridAlternatingNewtonLSODASolver(SteadyStateAlgorithm): - KISAO_ID: str = "KISAO_0000411" # Placeholder until it gets its own solver - ID: str = "steadystatestandard" def __init__(self, use_integration: bool = True, use_back_integration: bool = False, resolution: float = 1e-09, derivation_factor: float = 0.001, @@ -713,13 +730,24 @@ def __init__(self, use_integration: bool = True, use_back_integration: bool = Fa accept_negative_concentrations, iteration_limit, max_forward_duration, max_back_duration, target_criterion_distance, target_criterion_rate, units) - def get_copasi_id(self) -> str: - return CopasiHybridAlternatingNewtonLSODASolver.ID + @staticmethod + def get_copasi_id() -> str: + return "steadystatestandard" + + @staticmethod + def get_kisao_id() -> str: + return "KISAO_0000411" # Placeholder until it gets its own solver + + @staticmethod + def get_name() -> str: + return "Enhanced Newton" + + @staticmethod + def can_support_events(): + return False class PureNewtonRootFindingAlgorithm(SteadyStateAlgorithm): - KISAO_ID: str = "KISAO_0000409" - ID: str = "steadystatenewton" def __init__(self, resolution: float = 1e-09, derivation_factor: float = 0.001, accept_negative_concentrations: bool = False, iteration_limit: int = None, @@ -730,13 +758,24 @@ def __init__(self, resolution: float = 1e-09, derivation_factor: float = 0.001, accept_negative_concentrations, iteration_limit, max_forward_duration, max_back_duration, target_criterion_distance, target_criterion_rate, units) - def get_copasi_id(self) -> str: - return PureNewtonRootFindingAlgorithm.ID + @staticmethod + def get_copasi_id() -> str: + return "steadystatenewton" + + @staticmethod + def get_kisao_id() -> str: + return "KISAO_0000409" + + @staticmethod + def get_name() -> str: + return "Enhanced Newton" + + @staticmethod + def can_support_events(): + return False class PureIntegrationRootFindingAlgorithm(SteadyStateAlgorithm): - KISAO_ID: str = "" # No applicable term yet - ID: str = "steadystateintegration" def __init__(self, use_integration: bool = True, use_back_integration: bool = False, resolution: float = 1e-09, derivation_factor: float = 0.001, @@ -750,23 +789,45 @@ def __init__(self, use_integration: bool = True, use_back_integration: bool = Fa accept_negative_concentrations, iteration_limit, max_forward_duration, max_back_duration, target_criterion_distance, target_criterion_rate, units) - def get_copasi_id(self) -> str: - return PureIntegrationRootFindingAlgorithm.ID + @staticmethod + def get_copasi_id() -> str: + return "steadystateintegration" + + @staticmethod + def get_kisao_id() -> str: + return "" # No applicable term yet + + @staticmethod + def get_name() -> str: + return "Enhanced Newton" + + @staticmethod + def can_support_events(): + return False class GibsonBruckAlgorithm(CopasiAlgorithm): - KISAO_ID: str = "KISAO_0000027" - ID: str = "stochastic" - NAME: str = "Stochastic (Gibson + Bruck)" - CAN_SUPPORT_EVENTS: bool = True def __init__(self, max_internal_steps: int = None, random_seed: int = None, units: Units = Units.discrete): self.max_internal_steps = MaximumInternalStepsParameter(max_internal_steps) self.random_seed = RandomSeedParameter(random_seed) self._units = units - def get_copasi_id(self) -> str: - return GibsonBruckAlgorithm.ID + @staticmethod + def get_copasi_id() -> str: + return "stochastic" + + @staticmethod + def get_kisao_id() -> str: + return "KISAO_0000027" + + @staticmethod + def get_name() -> str: + return "Stochastic (Gibson + Bruck)" + + @staticmethod + def can_support_events(): + return True def get_unit_set(self) -> Units: return self._units @@ -779,18 +840,27 @@ def get_overrides(self) -> dict: class DirectMethodAlgorithm(CopasiAlgorithm): - KISAO_ID: str = "KISAO_0000029" - ID: str = "directmethod" - NAME: str = "Stochastic (Direct method)" - CAN_SUPPORT_EVENTS: bool = True def __init__(self, max_internal_steps: int = None, random_seed: int = None, units: Units = Units.discrete): self.max_internal_steps = MaximumInternalStepsParameter(max_internal_steps) self.random_seed = RandomSeedParameter(random_seed) self._units = units - def get_copasi_id(self) -> str: - return DirectMethodAlgorithm.ID + @staticmethod + def get_copasi_id() -> str: + return "directmethod" + + @staticmethod + def get_kisao_id() -> str: + return "KISAO_0000029" + + @staticmethod + def get_name() -> str: + return "Stochastic (Direct method)" + + @staticmethod + def can_support_events(): + return True def get_unit_set(self) -> Units: return self._units @@ -803,10 +873,6 @@ def get_overrides(self) -> dict: class TauLeapAlgorithm(CopasiAlgorithm): - KISAO_ID: str = "KISAO_0000039" - ID: str = "tauleap" - NAME: str = "Stochastic (τ-Leap)" - CAN_SUPPORT_EVENTS: bool = False def __init__(self, max_internal_steps: int = None, random_seed: int = None, epsilon: float = None, units: Units = Units.discrete): @@ -815,8 +881,21 @@ def __init__(self, max_internal_steps: int = None, random_seed: int = None, epsi self.epsilon = EpsilonParameter(epsilon) self._units = units - def get_copasi_id(self) -> str: - return TauLeapAlgorithm.ID + @staticmethod + def get_copasi_id() -> str: + return "tauleap" + + @staticmethod + def get_kisao_id() -> str: + return "KISAO_0000039" + + @staticmethod + def get_name() -> str: + return "Stochastic (τ-Leap)" + + @staticmethod + def can_support_events(): + return False def get_unit_set(self) -> Units: return self._units @@ -830,10 +909,6 @@ def get_overrides(self) -> dict: class AdaptiveSSATauLeapAlgorithm(CopasiAlgorithm): - KISAO_ID: str = "KISAO_0000048" - ID: str = "adaptivesa" - NAME: str = "Stochastic (Adaptive SSA/τ-Leap)" - CAN_SUPPORT_EVENTS: bool = True def __init__(self, max_internal_steps: int = None, random_seed: int = None, epsilon: float = None, units: Units = Units.discrete): @@ -842,8 +917,21 @@ def __init__(self, max_internal_steps: int = None, random_seed: int = None, epsi self.epsilon = EpsilonParameter(epsilon) self._units = units - def get_copasi_id(self) -> str: - return AdaptiveSSATauLeapAlgorithm.ID + @staticmethod + def get_copasi_id() -> str: + return "adaptivesa" + + @staticmethod + def get_kisao_id() -> str: + return "KISAO_0000048" + + @staticmethod + def get_name() -> str: + return "Stochastic (Adaptive SSA/τ-Leap)" + + @staticmethod + def can_support_events(): + return True def get_unit_set(self) -> Units: return self._units @@ -872,8 +960,21 @@ def __init__(self, relative_tolerance: float = None, absolute_tolerance: float = self.max_internal_steps = MaximumInternalStepsParameter(max_internal_steps) self.max_internal_step_size = MaximumInternalStepSizeParameter(max_internal_step_size) - def get_copasi_id(self) -> str: - return LsodaAlgorithm.ID + @staticmethod + def get_copasi_id() -> str: + return "lsoda" + + @staticmethod + def get_kisao_id() -> str: + return "KISAO_0000560" + + @staticmethod + def get_name() -> str: + return "Deterministic (LSODA)" + + @staticmethod + def can_support_events(): + return True def get_unit_set(self) -> Units: return self._units @@ -889,10 +990,6 @@ def get_overrides(self) -> dict: class Radau5Algorithm(CopasiAlgorithm): - KISAO_ID: str = "KISAO_0000304" - ID: str = "radau5" - NAME: str = "Deterministic (RADAU5)" - CAN_SUPPORT_EVENTS: bool = False def __init__(self, relative_tolerance: float = None, absolute_tolerance: float = None, integrate_reduced_model: bool = None, max_internal_steps: int = None, initial_step_size: float = None, @@ -904,8 +1001,21 @@ def __init__(self, relative_tolerance: float = None, absolute_tolerance: float = self.initial_step_size = InitialStepSizeParameter(initial_step_size) self._units = units - def get_copasi_id(self) -> str: - return Radau5Algorithm.ID + @staticmethod + def get_copasi_id() -> str: + return "radau5" + + @staticmethod + def get_kisao_id() -> str: + return "KISAO_0000304" + + @staticmethod + def get_name() -> str: + return "Deterministic (RADAU5)" + + @staticmethod + def can_support_events(): + return False def get_unit_set(self) -> Units: return self._units @@ -921,10 +1031,6 @@ def get_overrides(self) -> dict: class HybridLsodaAlgorithm(CopasiAlgorithm): - KISAO_ID: str = "KISAO_0000562" - ID: str = "hybridlsoda" - NAME: str = "Hybrid (LSODA)" - CAN_SUPPORT_EVENTS: bool = False def __init__(self, relative_tolerance: float = None, absolute_tolerance: float = None, integrate_reduced_model: bool = None, max_internal_steps: int = None, @@ -941,8 +1047,21 @@ def __init__(self, relative_tolerance: float = None, absolute_tolerance: float = self.partitioning_interval = PartitioningIntervalParameter(partitioning_interval) self._units = units - def get_copasi_id(self) -> str: - return HybridLsodaAlgorithm.ID + @staticmethod + def get_copasi_id() -> str: + return "hybridlsoda" + + @staticmethod + def get_kisao_id() -> str: + return "KISAO_0000562" + + @staticmethod + def get_name() -> str: + return "Hybrid (LSODA)" + + @staticmethod + def can_support_events(): + return False def get_unit_set(self) -> Units: return self._units @@ -962,10 +1081,6 @@ def get_overrides(self) -> dict: class HybridRungeKuttaAlgorithm(CopasiAlgorithm): - KISAO_ID: str = "KISAO_0000561" - ID: str = "hybrid" - NAME: str = "Hybrid (Runge-Kutta)" - CAN_SUPPORT_EVENTS: bool = False def __init__(self, max_internal_steps: int = None, random_seed: int = None, lower_limit: float = None, upper_limit: float = None, step_size: float = None, partitioning_interval: float = None, @@ -978,8 +1093,21 @@ def __init__(self, max_internal_steps: int = None, random_seed: int = None, lowe self.partitioning_interval = PartitioningIntervalParameter(partitioning_interval) self._units = units - def get_copasi_id(self) -> str: - return HybridRungeKuttaAlgorithm.ID + @staticmethod + def get_copasi_id() -> str: + return "hybrid" + + @staticmethod + def get_kisao_id() -> str: + return "KISAO_0000561" + + @staticmethod + def get_name() -> str: + return "Hybrid (Runge-Kutta)" + + @staticmethod + def can_support_events(): + return False def get_unit_set(self) -> Units: return self._units @@ -996,10 +1124,6 @@ def get_overrides(self) -> dict: class HybridRK45Algorithm(CopasiAlgorithm): - KISAO_ID: str = "KISAO_0000563" - ID: str = "hybridode45" - NAME: str = "Hybrid (RK-45)" - CAN_SUPPORT_EVENTS: bool = True def __init__(self, relative_tolerance: float = None, absolute_tolerance: float = None, max_internal_steps: int = None, random_seed: int = None, deterministic_reactions: list = None, @@ -1011,8 +1135,21 @@ def __init__(self, relative_tolerance: float = None, absolute_tolerance: float = self.deterministic_reactions = DeterministicReactionsParameter(deterministic_reactions) self._units = units - def get_copasi_id(self) -> str: - return HybridRK45Algorithm.ID + @staticmethod + def get_copasi_id() -> str: + return "hybridode45" + + @staticmethod + def get_kisao_id() -> str: + return "KISAO_0000563" + + @staticmethod + def get_name() -> str: + return "Hybrid (RK-45)" + + @staticmethod + def can_support_events(): + return True def get_unit_set(self) -> Units: return self._units @@ -1028,10 +1165,6 @@ def get_overrides(self) -> dict: class SDESolveRI5Algorithm(CopasiAlgorithm): - KISAO_ID: str = "KISAO_0000566" - ID: str = "sde" - NAME: str = "SDE Solver (RI5)" - CAN_SUPPORT_EVENTS: bool = True def __init__(self, absolute_tolerance: float = None, max_internal_steps: int = None, step_size: float = None, tolerance_for_root_finder: float = None, force_physical_correctness: bool = None, @@ -1043,8 +1176,21 @@ def __init__(self, absolute_tolerance: float = None, max_internal_steps: int = N self.force_physical_correctness = ForcePhysicalCorrectnessParameter(force_physical_correctness) self._units = units - def get_copasi_id(self) -> str: - return SDESolveRI5Algorithm.ID + @staticmethod + def get_copasi_id() -> str: + return "sde" + + @staticmethod + def get_kisao_id() -> str: + return "KISAO_0000566" + + @staticmethod + def get_name() -> str: + return "SDE Solver (RI5)" + + @staticmethod + def can_support_events(): + return True def get_unit_set(self) -> Units: return self._units @@ -1345,7 +1491,7 @@ def get_copasi_name(self, sedml_var: Variable) -> str: return self._sedml_var_to_copasi_name.get(sedml_var) def get_kisao_id_for_kisao_algorithm(self) -> str: - return self.algorithm.KISAO_ID + return self.algorithm.get_kisao_id() def get_copasi_algorithm_id(self) -> str: return self.algorithm.get_copasi_id() diff --git a/biosimulators_copasi/utils.py b/biosimulators_copasi/utils.py index 15a2365..99b0184 100644 --- a/biosimulators_copasi/utils.py +++ b/biosimulators_copasi/utils.py @@ -45,12 +45,12 @@ def get_algorithm(kisao_id: str, events_were_requested: bool = False, config: Co :obj:`CopasiAlgorithm`: The copasi algorithm deemed suitable """ algorithm_kisao_to_class_map: dict[str, CopasiAlgorithm] = \ - {CopasiAlgorithmType[alg_name].value.KISAO_ID: CopasiAlgorithmType[alg_name].value + {CopasiAlgorithmType[alg_name].value.get_kisao_id(): CopasiAlgorithmType[alg_name].value for alg_name, _ in CopasiAlgorithmType.__members__.items()} legal_alg_kisao_ids = \ [kisao for kisao, obj in algorithm_kisao_to_class_map.items() - if not events_were_requested or obj.CAN_SUPPORT_EVENTS] + if not events_were_requested or obj.can_support_events()] if kisao_id in legal_alg_kisao_ids: constructor = algorithm_kisao_to_class_map[kisao_id] diff --git a/tests/test_core.py b/tests/test_core.py index f02e1eb..4986997 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -520,9 +520,10 @@ def test_exec_sed_task_error_handling(self): exec_sed_task(task, variables) task.model.source = os.path.join(os.path.dirname(__file__), 'fixtures', 'model.xml') - task.simulation.output_end_time = 20.1 - with self.assertRaisesRegex(NotImplementedError, 'integer number of time points'): + task.simulation.number_of_steps = 20.1 + with self.assertRaisesRegex(ValueError, 'umber of points must be an integer'): exec_sed_task(task, variables) + task.simulation.number_of_steps = 20 task.simulation.output_start_time = 20. task.simulation.output_end_time = 20. diff --git a/tests/test_utils.py b/tests/test_utils.py index 1efa40f..1d2fa20 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -9,6 +9,8 @@ import os import unittest +from biosimulators_copasi.data_model import SteadyStateAlgorithm + class TestUtils(unittest.TestCase): @@ -31,14 +33,14 @@ def test_get_algorithm(self): utils.get_algorithm('KISAO_0000450') with mock.patch.dict(os.environ, {'ALGORITHM_SUBSTITUTION_POLICY': 'SAME_MATH'}): - self.assertEqual(utils.get_algorithm('KISAO_0000561', False).KISAO_ID, 'KISAO_0000561') + self.assertEqual(utils.get_algorithm('KISAO_0000561', False).get_kisao_id(), 'KISAO_0000561') with mock.patch.dict(os.environ, {'ALGORITHM_SUBSTITUTION_POLICY': 'SIMILAR_APPROXIMATIONS'}): - self.assertEqual(utils.get_algorithm('KISAO_0000561', False).KISAO_ID, 'KISAO_0000561') + self.assertEqual(utils.get_algorithm('KISAO_0000561', False).get_kisao_id(), 'KISAO_0000561') with mock.patch.dict(os.environ, {'ALGORITHM_SUBSTITUTION_POLICY': 'SAME_MATH'}): with self.assertRaises(ValueError): utils.get_algorithm('KISAO_0000561', True) with mock.patch.dict(os.environ, {'ALGORITHM_SUBSTITUTION_POLICY': 'SIMILAR_APPROXIMATIONS'}): - self.assertEqual(utils.get_algorithm('KISAO_0000561', True).KISAO_ID, 'KISAO_0000563') + self.assertEqual(utils.get_algorithm('KISAO_0000561', True).get_kisao_id(), 'KISAO_0000563') def test_convert_sedml_deterministic_reactions_to_copasi(self): pass @@ -56,7 +58,7 @@ def test_set_function_boolean_parameter(self): # Check whether the change applied task_settings = basico.get_task_settings(basico.T.TIME_COURSE) - self.assertEqual(alg.NAME, task_settings["method"]["name"]) + self.assertEqual(alg.get_name(), task_settings["method"]["name"]) saved_value = alg.force_physical_correctness.get_value() self.assertEqual(saved_value, task_settings["method"][alg.force_physical_correctness.NAME]) @@ -73,7 +75,7 @@ def test_set_function_integer_parameter(self): # Check whether the change applied task_settings = basico.get_task_settings(basico.T.TIME_COURSE) - self.assertEqual(alg.NAME, task_settings["method"]["name"]) + self.assertEqual(alg.get_name(), task_settings["method"]["name"]) saved_value = alg.max_internal_steps.get_value() self.assertEqual(saved_value, task_settings["method"][alg.max_internal_steps.NAME]) @@ -90,7 +92,7 @@ def test_set_function_float_parameter(self): # Check whether the change applied task_settings = basico.get_task_settings(basico.T.TIME_COURSE) - self.assertEqual(alg.NAME, task_settings["method"]["name"]) + self.assertEqual(alg.get_name(), task_settings["method"]["name"]) saved_value = alg.step_size.get_value() self.assertEqual(saved_value, task_settings["method"][alg.step_size.NAME]) @@ -110,7 +112,7 @@ def test_set_function_step_float_parameter(self): # Check whether the change applied task_settings = basico.get_task_settings(basico.T.TIME_COURSE) - self.assertEqual(runge_kutta_alg.NAME, task_settings["method"]["name"]) + self.assertEqual(runge_kutta_alg.get_name(), task_settings["method"]["name"]) saved_value = runge_kutta_alg.step_size.get_value() self.assertEqual(saved_value, task_settings["method"][runge_kutta_alg.step_size.NAME]) with self.assertRaises(KeyError): @@ -123,7 +125,7 @@ def test_set_function_step_float_parameter(self): # Check whether the change applied task_settings = basico.get_task_settings(basico.T.TIME_COURSE) - self.assertEqual(ri5_alg.NAME, task_settings["method"]["name"]) + self.assertEqual(ri5_alg.get_name(), task_settings["method"]["name"]) saved_value = ri5_alg.step_size.get_value() self.assertEqual(saved_value, task_settings["method"][ri5_alg.step_size.NAME]) with self.assertRaises(KeyError): @@ -142,7 +144,7 @@ def test_set_function_seed_integer_parameter(self): # Check if we have the algorithm, and the default is not a random seed. task_settings = basico.get_task_settings(basico.T.TIME_COURSE) - self.assertEqual(alg.NAME, task_settings["method"]["name"]) + self.assertEqual(alg.get_name(), task_settings["method"]["name"]) self.assertFalse(task_settings["method"]["Use Random Seed"]) # Now set the random seed parameter: @@ -198,7 +200,7 @@ def test_test_set_algorithm_parameter_value_errors(self): # Check if we have the algorithm. task_settings = basico.get_task_settings(basico.T.TIME_COURSE) - self.assertEqual(alg.NAME, task_settings["method"]["name"]) + self.assertEqual(alg.get_name(), task_settings["method"]["name"]) # Now check for errors with self.assertRaises(AttributeError): @@ -210,7 +212,7 @@ def test_test_set_algorithm_parameter_value_errors(self): alg.random_seed.set_value(True) def test_all_parameters_for_all_algorithms(self): - alg: data_model.GibsonBruckAlgorithm = data_model.GibsonBruckAlgorithm() + # alg: data_model.GibsonBruckAlgorithm = data_model.GibsonBruckAlgorithm() basico.create_datamodel() member: data_model.CopasiAlgorithmType @@ -229,14 +231,19 @@ def test_all_parameters_for_all_algorithms(self): continue replacement_settings = {"method": alg.get_method_settings()} - basico.set_task_settings(basico.T.TIME_COURSE, replacement_settings) + sim_type: str = basico.T.STEADY_STATE if isinstance(alg, SteadyStateAlgorithm) else basico.T.TIME_COURSE + basico.set_task_settings(sim_type, replacement_settings) # confirm our settings applied - task_settings = basico.get_task_settings(basico.T.TIME_COURSE) - self.assertEqual(alg.NAME, task_settings["method"]["name"]) + task_settings = basico.get_task_settings(sim_type) + self.assertEqual(alg.get_name(), task_settings["method"]["name"]) alg_params = list(alg.get_parameters_by_kisao().values()) param_name_to_value = {param.NAME: param.get_value() for param in alg_params} + # Temporary skip for Steady State + if sim_type == basico.T.STEADY_STATE: + continue + for basico_param_name, basico_param_value in task_settings["method"].items(): if basico_param_name == "name" or basico_param_name == "Subtype": continue # The above are not parameters to check @@ -294,6 +301,6 @@ def test_check_all_algorithm_args(self): data_model.SDESolveRI5Algorithm()] for alg in algorithms: - basico.set_task_settings(basico.T.TIME_COURSE, {"method": {"name": alg.NAME}}) + basico.set_task_settings(basico.T.TIME_COURSE, {"method": {"name": alg.get_name()}}) task_settings = basico.get_task_settings(basico.T.TIME_COURSE) - self.assertTrue(task_settings["method"]["name"] == alg.NAME) + self.assertTrue(task_settings["method"]["name"] == alg.get_name())