File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 11"""Basic tests."""
22
3+ import pytest
34import benchmark_models_petab as models
5+ from petab .v1 .calculate import calculate_llh
6+ import pandas as pd
47
58
69def test_constants ():
@@ -19,3 +22,35 @@ def test_get_problem():
1922def 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
You can’t perform that action at this time.
0 commit comments