Adding tests on predefined distributions
This commit is contained in:
parent
387fda67d8
commit
cc628cd1e6
2 changed files with 49 additions and 0 deletions
47
cara/tests/test_predefined_distributions.py
Normal file
47
cara/tests/test_predefined_distributions.py
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
import numpy as np
|
||||
import numpy.testing as npt
|
||||
import pytest
|
||||
|
||||
from cara.monte_carlo.data import activity_distributions, virus_distributions
|
||||
|
||||
# TODO: seed better the random number generators
|
||||
np.random.seed(0)
|
||||
|
||||
|
||||
# mean & std deviations from CERN-OPEN-2021-04 (Table 4)
|
||||
# NOTE: a mistake was corrected for the std deviation of the
|
||||
# "Moderate exercise" case (0.37 in the report, but should be 0.34)
|
||||
@pytest.mark.parametrize(
|
||||
"distribution, mean, std",[
|
||||
['Seated', 0.51, 0.053],
|
||||
|
||||
['Standing', 0.57, 0.053],
|
||||
|
||||
['Light activity', 1.24, 0.12],
|
||||
|
||||
['Moderate activity', 1.77, 0.34],
|
||||
|
||||
['Heavy exercise', 3.28, 0.72,],
|
||||
]
|
||||
)
|
||||
def test_activity_distributions(distribution, mean, std):
|
||||
activity = activity_distributions[distribution].build_model(size=1000000)
|
||||
npt.assert_allclose(activity.inhalation_rate.mean(), mean, atol=0.01)
|
||||
npt.assert_allclose(activity.inhalation_rate.std(), std, atol=0.01)
|
||||
|
||||
|
||||
# mean & std deviations from CERN-OPEN-2021-04 (Table 4) - with a refined
|
||||
# precision on the values
|
||||
@pytest.mark.parametrize(
|
||||
"distribution, mean, std",[
|
||||
['SARS_CoV_2', 6.59, 1.74],
|
||||
|
||||
['SARS_CoV_2_B117', 6.59, 1.74],
|
||||
|
||||
['SARS_CoV_2_P1', 6.59, 1.74],
|
||||
]
|
||||
)
|
||||
def test_viral_load_logdistribution(distribution, mean, std):
|
||||
virus = virus_distributions[distribution].build_model(size=1000000)
|
||||
npt.assert_allclose(np.log10(virus.viral_load_in_sputum).mean(), mean, atol=0.01)
|
||||
npt.assert_allclose(np.log10(virus.viral_load_in_sputum).std(), std, atol=0.01)
|
||||
|
|
@ -3,9 +3,11 @@ import numpy.testing as npt
|
|||
import pytest
|
||||
|
||||
from cara.monte_carlo import sampleable
|
||||
|
||||
# TODO: seed better the random number generators
|
||||
np.random.seed(2000)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"mean, std",[
|
||||
[1., 0.5],
|
||||
|
|
|
|||
Loading…
Reference in a new issue