Skip to content

Commit 03b6034

Browse files
author
Michael Becker
committed
tests: Fix tests and add additional test
1 parent 2121830 commit 03b6034

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

tests/test_app.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import altair as alt # type: ignore
77

88
from src.penn_chime.charts import new_admissions_chart, admitted_patients_chart
9-
from src.penn_chime.models import sir, sim_sir
9+
from src.penn_chime.models import sir, sim_sir, build_admissions_df
1010
from src.penn_chime.parameters import Parameters
1111
from src.penn_chime.presentation import display_header
1212
from src.penn_chime.settings import DEFAULTS
@@ -228,8 +228,14 @@ def test_parameters():
228228
assert round(param.infected_v[1], 0) == 43735
229229
assert round(param.recovered_v[30], 0) == 224048
230230
assert [d[0] for d in param.dispositions] == [100.0, 40.0, 20.0]
231-
assert [round(d[-1], 0) for d in param.dispositions] == [115.0, 46.0, 23.0]
231+
assert [round(d[-1], 0) for d in param.dispositions] == [1182.0, 473.0, 236.0]
232232

233233
# change n_days, make sure it cascades
234234
param.n_days = 2
235235
assert len(param.susceptible_v) == len(param.infected_v) == len(param.recovered_v) == param.n_days + 1 == 3
236+
237+
# test that admissions are being properly calculated (thanks @PhilMiller)
238+
admissions = build_admissions_df(param)
239+
cumulative_admissions = admissions.cumsum()
240+
diff = cumulative_admissions["Hospitalized"][1:-1] - (0.05*0.05 * (param.infected_v[1:-1] + param.recovered_v[1:-1]) - 100)
241+
assert (diff.abs() < 0.1).all()

0 commit comments

Comments
 (0)