Adding tests on vectorisation of Activity inhalation_rate and exhalation_rate
This commit is contained in:
parent
6df4a86670
commit
1564b9ea65
2 changed files with 26 additions and 7 deletions
|
|
@ -46,20 +46,37 @@ populations = [
|
|||
10, halftime, models.Mask(0.95, 0.15, np.array([0.3, 0.35])),
|
||||
models.Activity.types['Standing'],
|
||||
),
|
||||
# A population with some array component for inhalation_rate.
|
||||
models.Population(
|
||||
10, halftime, models.Mask.types['Type I'],
|
||||
models.Activity(np.array([0.51,0.57]), 0.57),
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"population, cm, expected_exposure",[
|
||||
[populations[1], KnownConcentrations(lambda t: 1.2), np.array([14.4, 14.4])],
|
||||
[populations[0], KnownConcentrations(lambda t: np.array([1.2, 2.4])), np.array([14.4, 28.8])],
|
||||
[populations[1], KnownConcentrations(lambda t: np.array([1.2, 2.4])), np.array([14.4, 28.8])],
|
||||
"population, cm, expected_exposure, expected_probability",[
|
||||
[populations[1], KnownConcentrations(lambda t: 1.2),
|
||||
np.array([14.4, 14.4]), np.array([99.6803184113, 99.5181053773])],
|
||||
|
||||
[populations[2], KnownConcentrations(lambda t: 1.2),
|
||||
np.array([14.4, 14.4]), np.array([99.4146994564, 99.6803184113])],
|
||||
|
||||
[populations[0], KnownConcentrations(lambda t: np.array([1.2, 2.4])),
|
||||
np.array([14.4, 28.8]), np.array([99.6803184113, 99.9989780368])],
|
||||
|
||||
[populations[1], KnownConcentrations(lambda t: np.array([1.2, 2.4])),
|
||||
np.array([14.4, 28.8]), np.array([99.6803184113, 99.9976777757])],
|
||||
])
|
||||
def test_exposure_model_ndarray(population, cm, expected_exposure):
|
||||
def test_exposure_model_ndarray(population, cm,
|
||||
expected_exposure, expected_probability):
|
||||
model = ExposureModel(cm, population)
|
||||
np.testing.assert_almost_equal(
|
||||
model.quanta_exposure(), expected_exposure
|
||||
)
|
||||
np.testing.assert_almost_equal(
|
||||
model.infection_probability(), expected_probability, decimal=10
|
||||
)
|
||||
|
||||
assert isinstance(model.infection_probability(), np.ndarray)
|
||||
assert isinstance(model.expected_new_cases(), np.ndarray)
|
||||
|
|
|
|||
|
|
@ -3,13 +3,14 @@ import pytest
|
|||
|
||||
import cara.models
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"override_params", [
|
||||
{'viral_load_in_sputum': np.array([5e8, 1e9])},
|
||||
{'coefficient_of_infectivity': np.array([0.02, 0.05])},
|
||||
{'η_exhale': np.array([0.92, 0.95])},
|
||||
{'η_leaks': np.array([0.15, 0.20])},
|
||||
|
||||
{'exhalation_rate': np.array([0.75, 0.81])},
|
||||
]
|
||||
)
|
||||
def test_infected_population_vectorisation(override_params):
|
||||
|
|
@ -19,6 +20,7 @@ def test_infected_population_vectorisation(override_params):
|
|||
'coefficient_of_infectivity': 0.02,
|
||||
'η_exhale': 0.95,
|
||||
'η_leaks': 0.15,
|
||||
'exhalation_rate': 0.75,
|
||||
}
|
||||
defaults.update(override_params)
|
||||
|
||||
|
|
@ -33,7 +35,7 @@ def test_infected_population_vectorisation(override_params):
|
|||
),
|
||||
activity=cara.models.Activity(
|
||||
0.51,
|
||||
0.75,
|
||||
defaults['exhalation_rate'],
|
||||
),
|
||||
virus=cara.models.Virus(
|
||||
halflife=defaults['virus_halflife'],
|
||||
|
|
|
|||
Loading…
Reference in a new issue