Skip to content

Commit

Permalink
PEtab import: Priors aren't support -> raise
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 470b468
Showing 1 changed file with 22 additions and 3 deletions.
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 470b468

Please sign in to comment.