|
4 | 4 | import pandas as pd |
5 | 5 | import pytest |
6 | 6 |
|
7 | | -import petab |
| 7 | +from petab.v2 import get_observable_df, get_parameter_df |
8 | 8 | from petab.v2.C import * |
9 | 9 | from petab.v2.calculate import ( |
10 | 10 | calculate_chi2, |
@@ -43,21 +43,21 @@ def model_simple(): |
43 | 43 | simulation_df[SIMULATION] = [2, 2, 19, 20] |
44 | 44 |
|
45 | 45 | expected_residuals = { |
46 | | - (2 - 0) / 2, |
47 | | - (2 - 1) / 2, |
48 | | - (19 - 20) / 3, |
49 | | - (20 - 22) / 3, |
| 46 | + (0 - 2) / 2, |
| 47 | + (1 - 2) / 2, |
| 48 | + (20 - 19) / 3, |
| 49 | + (22 - 20) / 3, |
50 | 50 | } |
51 | | - expected_residuals_nonorm = {2 - 0, 2 - 1, 19 - 20, 20 - 22} |
| 51 | + expected_residuals_nonorm = {0 - 2, 1 - 2, 20 - 19, 22 - 20} |
52 | 52 | expected_llh = ( |
53 | 53 | -0.5 * (np.array(list(expected_residuals)) ** 2).sum() |
54 | 54 | - 0.5 * np.log(2 * np.pi * np.array([2, 2, 3, 3]) ** 2).sum() |
55 | 55 | ) |
56 | 56 |
|
57 | 57 | return ( |
58 | 58 | measurement_df, |
59 | | - petab.get_observable_df(observable_df), |
60 | | - petab.get_parameter_df(parameter_df), |
| 59 | + get_observable_df(observable_df), |
| 60 | + get_parameter_df(parameter_df), |
61 | 61 | simulation_df, |
62 | 62 | expected_residuals, |
63 | 63 | expected_residuals_nonorm, |
@@ -93,8 +93,8 @@ def model_replicates(): |
93 | 93 | ) |
94 | 94 | simulation_df[SIMULATION] = [2, 2] |
95 | 95 |
|
96 | | - expected_residuals = {(2 - 0) / 2, (2 - 1) / 2} |
97 | | - expected_residuals_nonorm = {2 - 0, 2 - 1} |
| 96 | + expected_residuals = {(0 - 2) / 2, (1 - 2) / 2} |
| 97 | + expected_residuals_nonorm = {0 - 2, 1 - 2} |
98 | 98 | expected_llh = ( |
99 | 99 | -0.5 * (np.array(list(expected_residuals)) ** 2).sum() |
100 | 100 | - 0.5 * np.log(2 * np.pi * np.array([2, 2]) ** 2).sum() |
@@ -141,12 +141,12 @@ def model_scalings(): |
141 | 141 | simulation_df[SIMULATION] = [2, 3] |
142 | 142 |
|
143 | 143 | expected_residuals = { |
144 | | - (np.log(2) - np.log(0.5)) / 2, |
145 | | - (np.log(3) - np.log(1)) / 2, |
| 144 | + (np.log(0.5) - np.log(2)) / 2, |
| 145 | + (np.log(1) - np.log(3)) / 2, |
146 | 146 | } |
147 | 147 | expected_residuals_nonorm = { |
148 | | - np.log(2) - np.log(0.5), |
149 | | - np.log(3) - np.log(1), |
| 148 | + np.log(0.5) - np.log(2), |
| 149 | + np.log(1) - np.log(3), |
150 | 150 | } |
151 | 151 | expected_llh = ( |
152 | 152 | -0.5 * (np.array(list(expected_residuals)) ** 2).sum() |
@@ -204,12 +204,12 @@ def model_non_numeric_overrides(): |
204 | 204 | simulation_df[SIMULATION] = [2, 3] |
205 | 205 |
|
206 | 206 | expected_residuals = { |
207 | | - (np.log(2) - np.log(0.5)) / (2 * 7 + 8 + 4 + np.log(2)), |
208 | | - (np.log(3) - np.log(1)) / (2 * 2 + 3 + 4 + np.log(3)), |
| 207 | + (np.log(0.5) - np.log(2)) / (2 * 7 + 8 + 4 + np.log(2)), |
| 208 | + (np.log(1) - np.log(3)) / (2 * 2 + 3 + 4 + np.log(3)), |
209 | 209 | } |
210 | 210 | expected_residuals_nonorm = { |
211 | | - np.log(2) - np.log(0.5), |
212 | | - np.log(3) - np.log(1), |
| 211 | + np.log(0.5) - np.log(2), |
| 212 | + np.log(1) - np.log(3), |
213 | 213 | } |
214 | 214 | expected_llh = ( |
215 | 215 | -0.5 * (np.array(list(expected_residuals)) ** 2).sum() |
@@ -263,8 +263,8 @@ def model_custom_likelihood(): |
263 | 263 | ) |
264 | 264 | simulation_df[SIMULATION] = [2, 3] |
265 | 265 |
|
266 | | - expected_residuals = {(np.log(2) - np.log(0.5)) / 2, (3 - 2) / 1.5} |
267 | | - expected_residuals_nonorm = {np.log(2) - np.log(0.5), 3 - 2} |
| 266 | + expected_residuals = {(np.log(0.5) - np.log(2)) / 2, (2 - 3) / 1.5} |
| 267 | + expected_residuals_nonorm = {np.log(0.5) - np.log(2), 2 - 3} |
268 | 268 | expected_llh = ( |
269 | 269 | -np.abs(list(expected_residuals)).sum() |
270 | 270 | - np.log(2 * np.array([2, 1.5]) * np.array([0.5, 1])).sum() |
|
0 commit comments