Skip to content
Draft
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
35 changes: 35 additions & 0 deletions src/python/test/test_base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
"""Basic tests."""

import pytest
import benchmark_models_petab as models
from petab.v1.calculate import calculate_llh
import pandas as pd


def test_constants():
Expand All @@ -19,3 +22,35 @@ def test_get_problem():
def test_get_simulation_df():
assert models.get_simulation_df("Elowitz_Nature2000").empty is False
assert models.get_simulation_df("not a problem name") is None


@pytest.mark.parametrize("problem_id", models.MODELS)
def test_can_calculate_llh_from_simulation_df(problem_id):
"""Test whether log-likelihood can be calculated from the simulation df."""
problem = models.get_problem(problem_id)
sim_df = models.get_simulation_df(problem_id)

if sim_df is None:
pytest.skip(f"No simulation table for problem {problem_id}")

try:
calculate_llh(
observable_dfs=problem.observable_df,
measurement_dfs=problem.measurement_df,
parameter_dfs=problem.parameter_df,
simulation_dfs=sim_df,
)
except Exception:
with pd.option_context(
"display.max_rows",
None,
"display.max_columns",
None,
"display.width",
1000,
):
print("Simulation table:")
print(sim_df)
print("Measurement table:")
print(problem.measurement_df)
raise
Loading