Skip to content

Commit 3f2d744

Browse files
authored
Check population monotonicity
Check population monotonicity
2 parents 842e6b3 + ca55748 commit 3f2d744

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

tests/test_app.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
)
5252

5353
PARAM = Parameters(
54+
current_date=datetime(year=2020, month=3, day=28),
5455
current_hospitalized=100,
5556
doubling_time=6.0,
5657
market_share=0.05,
@@ -63,6 +64,7 @@
6364
)
6465

6566
HALVING_PARAM = Parameters(
67+
current_date=datetime(year=2020, month=3, day=28),
6668
current_hospitalized=100,
6769
doubling_time=6.0,
6870
market_share=0.05,
@@ -295,11 +297,11 @@ def test_model_raw_start():
295297

296298
assert first.susceptible == 499600.0
297299
assert round(second.infected, 0) == 449.0
298-
assert list(model.dispositions_df.iloc[0, :]) == [-43, date(year=2020, month=2, day=15), 1.0, 0.4, 0.2]
300+
assert list(model.dispositions_df.iloc[0, :]) == [-43, date(year=2020, month=2, day=14), 1.0, 0.4, 0.2]
299301
assert round(raw_df.recovered[30], 0) == 7083.0
300302

301303
d, dt, s, i, r = list(model.dispositions_df.iloc[60, :])
302-
assert dt == date(year=2020, month=4, day=15)
304+
assert dt == date(year=2020, month=4, day=14)
303305
assert [round(v, 0) for v in (d, s, i, r)] == [17, 549.0, 220.0, 110.0]
304306

305307

@@ -329,6 +331,16 @@ def test_model_raw_end():
329331
assert round(last.susceptible, 0) == 83391.0
330332

331333

334+
def test_model_monotonicity():
335+
param = copy(PARAM)
336+
model = Model(param)
337+
raw_df = model.raw_df
338+
339+
# Susceptible population should be non-increasing, and Recovered non-decreasing
340+
assert (raw_df.susceptible[1:] - raw_df.susceptible.shift(1)[1:] <= 0).all()
341+
assert (raw_df.recovered [1:] - raw_df.recovered. shift(1)[1:] >= 0).all()
342+
343+
332344
def test_model_cumulative_census():
333345
# test that census is being properly calculated
334346
param = copy(PARAM)

0 commit comments

Comments
 (0)