Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions petab/v2/experiments.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,14 @@ def get_experiment_df(
experiments_file: str | pd.DataFrame | Path | None,
) -> pd.DataFrame | None:
"""
Read the provided observable file into a ``pandas.Dataframe``.
Read the provided experiments file into a ``pandas.Dataframe``.

Arguments:
experiments_file: Name of the file to read from or pandas.Dataframe.

Returns:
Observable DataFrame
Experiments DataFrame
"""
if experiments_file is None:
return experiments_file

if isinstance(experiments_file, str | Path):
experiments_file = pd.read_csv(
Expand Down
17 changes: 15 additions & 2 deletions petab/v2/petab1to2.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,15 @@ def create_experiment_id(sim_cond_id: str, preeq_cond_id: str) -> str:
experiments.append(
{
v2.C.EXPERIMENT_ID: exp_id,
v2.C.CONDITION_ID: preeq_cond_id,
v2.C.TIME: v2.C.TIME_PREEQUILIBRATION,
v2.C.CONDITION_ID: preeq_cond_id,
}
)
experiments.append(
{
v2.C.EXPERIMENT_ID: exp_id,
v2.C.CONDITION_ID: sim_cond_id,
v2.C.TIME: 0,
v2.C.CONDITION_ID: sim_cond_id,
}
)
if experiments:
Expand Down Expand Up @@ -523,6 +523,19 @@ def update_prior(row):
errors="ignore",
)
# some columns were dropped in PEtab v2
if v1.C.INITIALIZATION_PRIOR_TYPE in df and (
df[v1.C.INITIALIZATION_PRIOR_TYPE].notna().any()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine for me to drop the notna check and warn regardless.

):
warnings.warn(
"Initialisation priors in parameter table are not supported "
"in PEtab v2.",
stacklevel=9,
)
if not (df[v1.C.PARAMETER_SCALE] == v1.C.LIN).all():
warnings.warn(
"Parameter scales are not supported in PEtab v2.",
stacklevel=9,
)
Comment on lines +534 to +538
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, fine for me to warn if the column is present at all

df.drop(
columns=[
v1.C.INITIALIZATION_PRIOR_TYPE,
Expand Down
7 changes: 7 additions & 0 deletions tests/v2/test_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ def test_petab1to2_remote():
@pytest.mark.filterwarnings(
"ignore:.*Using `log-normal` instead.*:UserWarning"
)
@pytest.mark.filterwarnings(
"ignore:.*Initialisation priors in parameter table are not supported.*:"
"UserWarning"
)
@pytest.mark.filterwarnings(
"ignore:.*Parameter scales are not supported in PEtab v2.*:UserWarning"
)
@parametrize_or_skip
def test_benchmark_collection(problem_id):
"""Test that we can upgrade all benchmark collection models."""
Expand Down
6 changes: 6 additions & 0 deletions tests/v2/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ def test_observable_table_round_trip():
assert observables == observables2


@pytest.mark.filterwarnings(
"ignore:.*Parameter scales are not supported in PEtab v2.*:UserWarning"
)
def test_condition_table_round_trip():
with tempfile.TemporaryDirectory() as tmp_dir:
petab1to2(example_dir_fujita / "Fujita.yaml", tmp_dir)
Expand All @@ -59,6 +62,9 @@ def test_condition_table_round_trip():
assert conditions == conditions2


@pytest.mark.filterwarnings(
"ignore:.*Parameter scales are not supported in PEtab v2.*:UserWarning"
)
def test_assert_valid():
problem = petab1to2(example_dir_fujita / "Fujita.yaml")
problem.assert_valid()
Expand Down
Loading