Skip to content

Commit

Permalink
Replaced Usage of roadrunner, amici, petab strings with constants
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulJonasJost committed Sep 9, 2024
1 parent 53c8e61 commit 4c4e978
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
4 changes: 4 additions & 0 deletions pypesto/C.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ class EnsembleType(Enum):
X0 = "x0"
ID = "id"

AMICI = "amici"
ROADRUNNER = "roadrunner"
PETAB = "petab"


###############################################################################
# HIERARCHICAL SCALING + OFFSET
Expand Down
17 changes: 10 additions & 7 deletions pypesto/petab/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@
roadrunner = None

from ..C import (
AMICI,
CENSORED,
ORDINAL,
ORDINAL_OPTIONS,
PETAB,
ROADRUNNER,
SEMIQUANTITATIVE,
SPLINE_APPROXIMATION_OPTIONS,
)
Expand Down Expand Up @@ -74,7 +77,7 @@ def __init__(
validate_petab_hierarchical: bool = True,
hierarchical: bool = False,
inner_options: dict | None = None,
simulator_type: str = "amici",
simulator_type: str = AMICI,
simulator: petab.Simulator | None = None,
rr: roadrunner.RoadRunner | None = None,
):
Expand Down Expand Up @@ -168,7 +171,7 @@ def __init__(

self.simulator_type = simulator_type
self.simulator = simulator
if simulator_type == "petab" and simulator is None:
if simulator_type == PETAB and simulator is None:
raise ValueError(
"A petab simulator object must be provided if the simulator "
"type is 'petab'."
Expand All @@ -180,7 +183,7 @@ def from_yaml(
yaml_config: dict | str,
output_folder: str = None,
model_name: str = None,
simulator_type: str = "amici",
simulator_type: str = AMICI,
) -> PetabImporter:
"""Simplified constructor using a petab yaml file."""
petab_problem = petab.Problem.from_yaml(yaml_config)
Expand Down Expand Up @@ -288,7 +291,7 @@ def create_startpoint_method(self, **kwargs) -> StartpointMethod:

def create_objective_creator(self) -> ObjectiveCreator:
"""Choose factory depending on the simulator type."""
if self.simulator_type == "amici":
if self.simulator_type == AMICI:
return AmiciObjectiveCreator(
petab_problem=self.petab_problem,
output_folder=self.output_folder,
Expand All @@ -298,11 +301,11 @@ def create_objective_creator(self) -> ObjectiveCreator:
non_quantitative_data_types=self._non_quantitative_data_types,
validate_petab=self.validate_petab,
)
elif self.simulator_type == "petab":
elif self.simulator_type == PETAB:
return PetabSimulatorObjectiveCreator(
petab_problem=self.petab_problem, simulator=self.simulator
)
elif self.simulator_type == "roadrunner":
elif self.simulator_type == ROADRUNNER:
return RoadRunnerObjectiveCreator(
petab_problem=self.petab_problem, rr=self.roadrunner_instance
)
Expand Down Expand Up @@ -447,7 +450,7 @@ def create_predictor(
condition_ids: Sequence[str] = None,
) -> AmiciPredictor:
"""See :meth:`AmiciObjectiveCreator.create_predictor`."""
if self.simulator_type != "amici":
if self.simulator_type != AMICI:
raise ValueError(
"Predictor can only be created for amici models and is "
"supposed to be created from the AmiciObjectiveCreator."
Expand Down

0 comments on commit 4c4e978

Please sign in to comment.