Skip to content

Commit

Permalink
update test_cli.py
Browse files Browse the repository at this point in the history
  • Loading branch information
dilpath committed Jan 1, 2025
1 parent 1735098 commit 84d099d
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 25 deletions.
21 changes: 13 additions & 8 deletions petab_select/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,16 +551,21 @@ def to_petab(
if set_estimated_parameters is None and self.estimated_parameters:
set_estimated_parameters = True

if set_estimated_parameters and (
missing_parameter_estimates := set(self.parameters).difference(
if set_estimated_parameters:
required_estimates = {
parameter_id
for parameter_id, value in self.parameters.items()
if value == ESTIMATE
}
missing_estimates = required_estimates.difference(
self.estimated_parameters
)
):
raise ValueError(
"Try again with `set_estimated_parameters=False`, because "
"some parameter estimates are missing. Missing estimates for: "
f"`{missing_parameter_estimates}`."
)
if missing_estimates:
raise ValueError(
"Try again with `set_estimated_parameters=False`, because "
"some parameter estimates are missing. Missing estimates for: "
f"`{missing_estimates}`."
)

for parameter_id, parameter_value in self.parameters.items():
# If the parameter is to be estimated.
Expand Down
16 changes: 11 additions & 5 deletions test/cli/input/model.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
- criteria: {}
- model_subspace_id: M
model_subspace_indices:
- 0
- 1
- 1
criteria: {}
model_hash: M-011
model_subspace_petab_yaml: ../../../doc/examples/model_selection/petab_problem.yaml
estimated_parameters:
k2: 0.15
k3: 0.0
model_id: model
parameters:
k1: 0.2
k2: estimate
k3: estimate
estimated_parameters:
k2: 0.15
k3: 0.0
petab_yaml: ../../../doc/examples/model_selection/petab_problem.yaml
24 changes: 13 additions & 11 deletions test/cli/input/models.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
- criteria: {}
model_id: model_1
model_subspace_id: M
- model_subspace_id: M
model_subspace_indices:
- 0
- 1
- 1
criteria: {}
model_hash: M-011
model_subspace_petab_yaml: ../../../doc/examples/model_selection/petab_problem.yaml
estimated_parameters:
k2: 0.15
k3: 0.0
model_id: model_1
parameters:
k1: 0.2
k2: estimate
k3: estimate
estimated_parameters:
k2: 0.15
k3: 0.0
petab_yaml: ../../../doc/examples/model_selection/petab_problem.yaml
- criteria: {}
model_id: model_2
model_subspace_id: M
- model_subspace_id: M
model_subspace_indices:
- 1
- 1
- 0
criteria: {}
model_hash: M-110
model_subspace_petab_yaml: ../../../doc/examples/model_selection/petab_problem.yaml
model_id: model_2
parameters:
k1: estimate
k2: estimate
k3: 0
petab_yaml: ../../../doc/examples/model_selection/petab_problem.yaml
1 change: 0 additions & 1 deletion test/cli/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ def test_model_to_petab(
],
)

print(result.stdout)
# The new PEtab problem YAML file is output to stdout correctly.
assert (
result.stdout == f'{base_dir / "output" / "model" / "problem.yaml"}\n'
Expand Down

0 comments on commit 84d099d

Please sign in to comment.