Skip to content

Commit 705d049

Browse files
committed
Add conservation test
1 parent 76dd9b9 commit 705d049

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/test_app.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,23 @@ def test_model_raw_start():
304304
assert [round(v, 0) for v in (d, s, i, r)] == [17, 549.0, 220.0, 110.0]
305305

306306

307+
def test_model_conservation():
308+
p = copy(PARAM)
309+
m = Model(p)
310+
raw_df = m.raw_df
311+
312+
assert (0.0 <= raw_df.susceptible).all()
313+
assert (0.0 <= raw_df.infected).all()
314+
assert (0.0 <= raw_df.recovered).all()
315+
316+
diff = raw_df.susceptible + raw_df.infected + raw_df.recovered - p.population
317+
assert (diff < 0.1).all()
318+
319+
assert (raw_df.susceptible <= p.population).all()
320+
assert (raw_df.infected <= p.population).all()
321+
assert (raw_df.recovered <= p.population).all()
322+
323+
307324
def test_model_raw_end():
308325
param = copy(PARAM)
309326
model = Model(param)

0 commit comments

Comments
 (0)