Skip to content

Commit e21e147

Browse files
committed
Check simulation tables
Related to #278.
1 parent 5bad863 commit e21e147

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

src/python/test/test_base.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
"""Basic tests."""
22

3+
import pytest
34
import benchmark_models_petab as models
5+
from petab.v1.calculate import calculate_llh
6+
import pandas as pd
47

58

69
def test_constants():
@@ -19,3 +22,35 @@ def test_get_problem():
1922
def test_get_simulation_df():
2023
assert models.get_simulation_df("Elowitz_Nature2000").empty is False
2124
assert models.get_simulation_df("not a problem name") is None
25+
26+
27+
@pytest.mark.parametrize("problem_id", models.MODELS)
28+
def test_can_calculate_llh_from_simulation_df(problem_id):
29+
"""Test whether log-likelihood can be calculated from the simulation df."""
30+
problem = models.get_problem(problem_id)
31+
sim_df = models.get_simulation_df(problem_id)
32+
33+
if sim_df is None:
34+
pytest.skip(f"No simulation table for problem {problem_id}")
35+
36+
try:
37+
calculate_llh(
38+
observable_dfs=problem.observable_df,
39+
measurement_dfs=problem.measurement_df,
40+
parameter_dfs=problem.parameter_df,
41+
simulation_dfs=sim_df,
42+
)
43+
except Exception:
44+
with pd.option_context(
45+
"display.max_rows",
46+
None,
47+
"display.max_columns",
48+
None,
49+
"display.width",
50+
1000,
51+
):
52+
print("Simulation table:")
53+
print(sim_df)
54+
print("Measurement table:")
55+
print(problem.measurement_df)
56+
raise

0 commit comments

Comments
 (0)