Closed kellypierce closed 3 years ago
Checks pass here, but locally I have an error collecting tests:
ERROR collecting tests/test_partition.py
ImportError while importing test module '/Users/kpierce/episimlab/tests/test_partition.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
esl-venv/lib/python3.7/importlib/__init__.py:127: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
tests/test_partition.py:12: in <module>
from episimlab.partition import toy, from_travel, partition
episimlab/partition/toy.py:12: in <module>
from ..utils import get_var_dims, get_int_per_day
episimlab/utils/__init__.py:1: in <module>
from .discrete_time_approx import *
episimlab/utils/discrete_time_approx.py:2: in <module>
from ..cy_utils.cy_utils import discrete_time_approx_wrapper as cy_dta
E ModuleNotFoundError: No module named 'episimlab.cy_utils.cy_utils'
... could be a local environment problem; but noting in case this is not covered by the tox checks and needs some attention.
E ModuleNotFoundError: No module named 'episimlab.cy_utils.cy_utils'
... could be a local environment problem; but noting in case this is not covered by the tox checks and needs some attention.
git mv -r src/episimlab .
. Re-building Cython modules should fix this locally:python setup.py build_ext --inplace
Might need to specify a C compiler with -fopenmp support, e.g. if below error is raised:
# clang: error: unsupported option '-fopenmp'
# Set env to compiler that supports this flag
CC='gcc-11' python setup.py build_ext --inplace
Similarly, running tests with tox
should always pass:
C='gcc-10' tox
There are a couple of redundant methods and testing bugs to sort out; opening a PR to facilitate review and resolution of those issues.
This PR adds module
partition.py
, which containsclass Partitioning
as an updated implementation of probabilistic contact partitioning for a single time point given travel and contact rate data.There is some duplication between methods in this class and methods in
SetupPhiWithPartitioning
infrom_travel.py
that should be resolved during review. MethodSetupPhiWithPartitioning._partition_contacts()
andSetupPhiWithPartitioning._contact_matrix()
are redundant with methods of the corresponding names inPartitioning
. Code review should resolve the organization that makes the most sense.Methods in
Partitioning
were tested with the addition ofclass TestPartitioning
totest_partition.py
. These tests cover legacy test cases and add one new test case (index 8) with a more complicated contact structure. Relevant tests passed at commitc587223
but are broken after mergingmain
into this branch.