Skip to content

Commit

Permalink
PEtab import: Priors aren't support -> raise (#384)
Browse files Browse the repository at this point in the history
So far, parPE doesn't support priors.

Most of the PEtab import was written before priors were introduced. That's why unfortunately there wasn't any warning/error in place so far.
  • Loading branch information
dweindl committed Sep 16, 2024
1 parent 0b7fe48 commit 157fd81
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
5 changes: 3 additions & 2 deletions benchmark_collection/all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ Borghans_BiophysChem1997
Crauste_CellSystems2017
Elowitz_Nature2000
Fujita_SciSignal2010
Schwen_PONE2014
Sneyd_PNAS2002
Weber_BMC2015
Zheng_PNAS2012
Expand Down Expand Up @@ -47,7 +46,9 @@ Zheng_PNAS2012
# Brannmark_JBC2010 FAILED: Expected llh 283.778227541074, got nllh 141.889034
# Lucarelli_CellSystems2018
# Fiedler_BMC2016 FAILED: Expected llh -117.16780323362, got nllh 109391.496205

#
# Unsupported priors:
# Schwen_PONE2014
for model_name in $expected_to_work; do
printf '=%.0s' {1..20}
printf %s "${model_name}"
Expand Down
25 changes: 22 additions & 3 deletions python/parpe/hdf5_pe_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ def __init__(self,
self.petab_problem: petab.Problem = petab_problem
self.amici_model: amici.Model = amici_model

# ensure we have valid inputs
petab.lint_problem(self.petab_problem)

# index for no reference/preequilibration condition
self.NO_PREEQ_CONDITION_IDX: int = NO_PREEQ_CONDITION_IDX

Expand All @@ -105,6 +102,28 @@ def __init__(self,
# hdf5 dataset compression
self.compression = "gzip"

self._check_support()

def _check_support(self):
"""
Check if the model is supported by parPE
"""
# ensure we have valid inputs
petab.lint_problem(self.petab_problem)

# We can't handle priors yet
# Initialization priors would work in principle when we sample
# starting points using petab. However, the current parpe C++
# resampling would ignore the initialization prior.
# And they wouldn't be supported for hierarchical optimization.
parameter_df = self.petab_problem.parameter_df
for col_id in [
ptc.INITIALIZATION_PRIOR_TYPE, ptc.INITIALIZATION_PRIOR_PARAMETERS,
ptc.OBJECTIVE_PRIOR_TYPE, ptc.OBJECTIVE_PRIOR_PARAMETERS
]:
if (col := parameter_df.get(col_id)) is not None and col.notna().any():
raise NotImplementedError("Priors are not supported yet.")

def generate_file(self, hdf5_file_name: str) -> None:
"""
Create the output file
Expand Down

0 comments on commit 157fd81

Please sign in to comment.