Skip to content

Commit

Permalink
errmsg
Browse files Browse the repository at this point in the history
  • Loading branch information
dweindl committed Nov 6, 2023
1 parent a0b6ac0 commit 63c1e46
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 7 additions & 1 deletion petab/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,13 @@ def get_priors_from_df(
par_to_estimate = parameter_df.loc[parameter_df[ESTIMATE] == 1]

if parameter_ids:
par_to_estimate = par_to_estimate.loc[parameter_ids, :]
try:
par_to_estimate = par_to_estimate.loc[parameter_ids, :]
except KeyError as e:
missing_ids = set(parameter_ids) - set(par_to_estimate.index)
raise KeyError(
f"Parameter table does not contain estimated parameter(s) {missing_ids}."
) from e

prior_list = []
for _, row in par_to_estimate.iterrows():
Expand Down
5 changes: 5 additions & 0 deletions tests/test_petab.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,11 @@ def test_get_priors_from_df():
assert len(prior_list_subset) == 2
assert prior_list_subset == [prior_list[1], prior_list[0]]

with pytest.raises(KeyError, match="Parameter table does not contain"):
petab.get_priors_from_df(
parameter_df, mode=INITIALIZATION, parameter_ids=["non_existent"]
)


def test_startpoint_sampling(fujita_model_scaling):
n_starts = 10
Expand Down

0 comments on commit 63c1e46

Please sign in to comment.