@@ -293,7 +293,6 @@ def test_model_raw_start():
293
293
first = raw_df .iloc [0 , :]
294
294
second = raw_df .iloc [1 , :]
295
295
296
- assert first .susceptible + first .infected + first .recovered == param .population
297
296
assert first .susceptible == 499600.0
298
297
assert round (second .infected , 0 ) == 449.0
299
298
assert list (model .dispositions_df .iloc [0 , :]) == [- 43 , date (year = 2020 , month = 2 , day = 15 ), 1.0 , 0.4 , 0.2 ]
@@ -304,13 +303,29 @@ def test_model_raw_start():
304
303
assert [round (v , 0 ) for v in (d , s , i , r )] == [17 , 549.0 , 220.0 , 110.0 ]
305
304
306
305
306
+ def test_model_conservation ():
307
+ p = copy (PARAM )
308
+ m = Model (p )
309
+ raw_df = m .raw_df
310
+
311
+ assert (0.0 <= raw_df .susceptible ).all ()
312
+ assert (0.0 <= raw_df .infected ).all ()
313
+ assert (0.0 <= raw_df .recovered ).all ()
314
+
315
+ diff = raw_df .susceptible + raw_df .infected + raw_df .recovered - p .population
316
+ assert (diff < 0.1 ).all ()
317
+
318
+ assert (raw_df .susceptible <= p .population ).all ()
319
+ assert (raw_df .infected <= p .population ).all ()
320
+ assert (raw_df .recovered <= p .population ).all ()
321
+
322
+
307
323
def test_model_raw_end ():
308
324
param = copy (PARAM )
309
325
model = Model (param )
310
326
raw_df = model .raw_df
311
327
312
328
last = raw_df .iloc [- 1 , :]
313
- assert last .susceptible + last .infected + last .recovered == param .population
314
329
assert round (last .susceptible , 0 ) == 83391.0
315
330
316
331
0 commit comments