UT-Covid / episimlab

Framework for development of epidemiological models
https://ut-covid.github.io/episimlab/
BSD 3-Clause "New" or "Revised" License
3 stars 1 forks source link

37 incidence compt #38

Closed kellypierce closed 3 years ago

kellypierce commented 3 years ago

Adding the cumulative incidence compartments to the xarray output.

kellypierce commented 3 years ago

Currently debugging a test failure in test_bf_seir.TestBruteForceSEIR.test_can_run_step:

>           assert abs(census.sum()) <= 1e-8
E           AssertionError: assert <xarray.DataArray ()>\narray(15.) <= 1e-08
test_bf_seir.py:28: AssertionError
=========================== short test summary info ============================
FAILED test_bf_seir.py::TestBruteForceSEIR::test_can_run_step[True-0.75-realistic-24-5-10]
FAILED test_bf_seir.py::TestBruteForceSEIR::test_can_run_step[True-0.75-ones-24-3-10]
FAILED test_bf_seir.py::TestBruteForceSEIR::test_can_run_step[True-0.75-ones-24-5-10]
FAILED test_bf_seir.py::TestBruteForceSEIR::test_can_run_step[False-0.75-realistic-24-5-10]
========================= 4 failed, 4 passed in 39.02s =========================

I added some code to the test to dig into the error:

https://github.com/eho-tacc/episimlab/blob/5aac7c09233deff9bb63f92ceb3b9a36d83f65e3/tests/test_seir/test_bf_seir.py#L31

Inspection in the debugger shows that not all the population leaving S arrives in E:

<class 'dict'>: 
{'S': <xarray.DataArray ()> array(-29.)
'E': <xarray.DataArray ()>array(16.)
'Pa': <xarray.DataArray ()>array(0.)
'Py': <xarray.DataArray ()>array(0.)
'Ia': <xarray.DataArray ()>array(-132.)
'Iy': <xarray.DataArray ()>array(0.)
'Ih': <xarray.DataArray ()>array(0.)
'R': <xarray.DataArray ()>array(132.)
'D': <xarray.DataArray ()>array(0.)}

@eho-tacc any thoughts?

ethho commented 3 years ago

Can reproduce on 5aac7c0 with poetry run pytest -k 'TestBruteForceSEIR' --pdb

ethho commented 3 years ago

poetry run pytest tests/test_seir/test_bf_seir.py failing on 7747d4c. Passing on 41bf4e8. Addition was one critical line in the SEIR engine that we should also patch on main if necessary:

https://github.com/eho-tacc/episimlab/blob/41bf4e8e14743ad4ec321965b29a42369a2a33b1/episimlab/seir/brute_force.py#L182-L182

ethho commented 3 years ago

CI fails as expected:

FAILED tests/test_seir/test_bf_cython_seir.py::TestBruteForceCythonSEIR::test_same_as_python[0.75-realistic-24-5-False]
===== 1 failed, 171 passed, 1 skipped, 2167 warnings in 146.85s (0:02:26) ======

Cython implementation does not yet have above fix implemented, but this should be quick...