Closed ethho closed 2 years ago
Prototype implementation in https://github.com/eho-tacc/episimlab-markov/
Migrated prototype notebook to markov
branch on this repo: https://github.com/eho-tacc/episimlab/blob/markov/notebooks/20210731_markov_sandbox.ipynb. Process FOI
in this notebook implements the above requested LooplessFOI
in its foi
method. foi
method is confirmed to produce equivalent output to the (current) brute force method in brute_force_foi
.
Fixed in v2 (#40)
Problem
Force of infection calculation is implemented with naive for looping in the
BruteForceCythonFOI
process: https://github.com/eho-tacc/episimlab/blob/e888ae7d7f1d1773c271c53320a7ea8a341b40d4/episimlab/foi/bf_cython.py#L15This wraps the lower level Cython API
bf_cython_engine._brute_force_foi
: https://github.com/eho-tacc/episimlab/blob/e888ae7d7f1d1773c271c53320a7ea8a341b40d4/episimlab/foi/bf_cython_engine.pyx#L69It is relatively straightforward to perform this arithmetic on arrays directly using numpy (or xarray, which uses numpy backend): https://github.com/eho-tacc/episimlab/blob/e888ae7d7f1d1773c271c53320a7ea8a341b40d4/episimlab/foi/bf_cython_engine.pyx#L156
Objective
LooplessFOI
that produces the same outputs asBruteForceCythonFOI
in unit tests, but has no nested for loop structure.episimlab.foi.loopless
tests/test_foi/test_loopless.py
that checks the following:run_step
method error-free, as in https://github.com/eho-tacc/episimlab/blob/e888ae7d7f1d1773c271c53320a7ea8a341b40d4/tests/test_foi/test_bf_cython_foi.py#L10BruteForceCythonFOI
, as in https://github.com/eho-tacc/episimlab/blob/e888ae7d7f1d1773c271c53320a7ea8a341b40d4/tests/test_foi/test_bf_cython_foi.py#L33