Skip to content

Commit

Permalink
add warning for fixed parameters with prior in petab
Browse files Browse the repository at this point in the history
  • Loading branch information
arrjon committed Jun 13, 2024
1 parent 3394a79 commit b178863
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pypesto/objective/priors.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
import math
from collections.abc import Sequence
from typing import Callable, Optional, Union
from typing import Callable, Union

import numpy as np

Expand Down Expand Up @@ -51,7 +51,7 @@ class NegLogParameterPriors(ObjectiveBase):
def __init__(
self,
prior_list: list[dict],
x_names: Optional[Sequence[str]] = None,
x_names: Sequence[str] = None,
):
"""
Initialize.
Expand Down
10 changes: 10 additions & 0 deletions pypesto/objective/roadrunner/petab_importer_roadrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""
from __future__ import annotations

import logging
import numbers
import re
from collections.abc import Iterable
Expand All @@ -32,6 +33,8 @@
from .roadrunner_calculator import RoadRunnerCalculator
from .utils import ExpData

logger = logging.getLogger(__name__)


class PetabImporterRR:
"""
Expand Down Expand Up @@ -279,6 +282,13 @@ def create_prior(self) -> NegLogParameterPriors | None:
isinstance(prior_type_entry, str)
and prior_type_entry != petab.PARAMETER_SCALE_UNIFORM
):
# check if parameter for which prior is defined is a fixed parameter
if x_id in self.petab_problem.x_fixed_ids:
logger.warning(
f"Parameter {x_id} is marked as fixed but has a "
f"prior defined. This might be unintended."
)

prior_params = [
float(param)
for param in self.petab_problem.parameter_df.loc[
Expand Down
7 changes: 7 additions & 0 deletions pypesto/petab/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,13 @@ def create_prior(self) -> NegLogParameterPriors | None:
isinstance(prior_type_entry, str)
and prior_type_entry != petab.PARAMETER_SCALE_UNIFORM
):
# check if parameter for which prior is defined is a fixed parameter
if x_id in self.petab_problem.x_fixed_ids:
logger.warning(
f"Parameter {x_id} is marked as fixed but has a "
f"prior defined. This might be unintended."
)

prior_params = [
float(param)
for param in self.petab_problem.parameter_df.loc[
Expand Down

0 comments on commit b178863

Please sign in to comment.