Skip to content

Commit 4fe0920

Browse files
committed
Test that both fitting modes produce equivalent results when their inputs are compatible
1 parent 90c7b1b commit 4fe0920

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/penn_chime/test_models.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
import pytest
44
import pandas as pd
55
import numpy as np
6+
from datetime import timedelta
67

78
from src.penn_chime.models import (
89
sir,
910
sim_sir_df,
1011
get_growth_rate,
12+
SimSirModel,
1113
)
1214

1315
from src.penn_chime.constants import EPSILON
@@ -100,6 +102,20 @@ def test_model(model, param):
100102
assert model.r_t == 2.307298374881539
101103
assert model.r_naught == 2.7144686763312222
102104
assert model.doubling_time_t == 7.764405988534983
105+
assert model.i_day == 43
106+
107+
108+
def test_model_first_hosp_fit(param):
109+
param.date_first_hospitalized = param.current_date - timedelta(days=43)
110+
param.doubling_time = None
111+
112+
my_model = SimSirModel(param)
113+
114+
assert my_model.intrinsic_growth_rate == 0.12246204830937302
115+
assert abs(my_model.beta - 4.21501347256401e-07) < EPSILON
116+
assert my_model.r_t == 2.307298374881539
117+
assert my_model.r_naught == 2.7144686763312222
118+
assert my_model.doubling_time_t == 7.764405988534983
103119

104120

105121
def test_model_raw_start(model, param):

0 commit comments

Comments
 (0)