Skip to content

Commit

Permalink
moved default infectiousness_days value to SARSCoV2 class and added a…
Browse files Browse the repository at this point in the history
…nother test scenario
  • Loading branch information
lrdossan committed Oct 10, 2022
1 parent d50d63d commit 12b7b57
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion caimira/apps/calculator/report_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def scenario_statistics(mc_model: mc.ExposureModel, sample_times: typing.List[fl
model = mc_model.build_model(size=_DEFAULT_MC_SAMPLE_SIZE)
if (compute_prob_exposure):
# It means we have data to calculate the total_probability_rule
prob_probabilistic_exposure = np.array(model.total_probability_rule()).mean()
prob_probabilistic_exposure = model.total_probability_rule()
else:
prob_probabilistic_exposure = 0.

Expand Down
6 changes: 4 additions & 2 deletions caimira/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ class Virus:
types: typing.ClassVar[typing.Dict[str, "Virus"]]

#: Number of days the infector is contagious
infectiousness_days: int = 14
infectiousness_days: int

def halflife(self, humidity: _VectorisedFloat, inside_temp: _VectorisedFloat) -> _VectorisedFloat:
# Biological decay (inactivation of the virus in air) - virus
Expand All @@ -454,7 +454,9 @@ def decay_constant(self, humidity: _VectorisedFloat, inside_temp: _VectorisedFlo

@dataclass(frozen=True)
class SARSCoV2(Virus):

#: Number of days the infector is contagious
infectiousness_days: int = 14

def halflife(self, humidity: _VectorisedFloat, inside_temp: _VectorisedFloat) -> _VectorisedFloat:
"""
Half-life changes with humidity level. Here is implemented a simple
Expand Down
5 changes: 3 additions & 2 deletions caimira/tests/models/test_exposure_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,9 @@ def test_prob_meet_infected_person(pop, cases, AB, exposed, infected, prob_meet_
@pytest.mark.parametrize(
"exposed_population, cm, pop, cases, AB, probabilistic_exposure_probability",[
[10, known_concentrations(lambda t: 36.),
100000, 68, 5, 41.51920685],
100000, 68, 5, 41.50971131],
[10, known_concentrations(lambda t: 0.2),
100000, 68, 5, 2.185785075],
[20, known_concentrations(lambda t: 72.),
100000, 68, 5, 64.09068488],
[30, known_concentrations(lambda t: 1.2),
Expand All @@ -289,7 +291,6 @@ def test_probabilistic_exposure_probability(exposed_population, cm,
models.Activity.types['Standing'], host_immunity=0.,)
model = ExposureModel(cm, (), population, models.Cases(geographic_population=pop,
geographic_cases=cases, ascertainment_bias=AB),)

np.testing.assert_allclose(
model.total_probability_rule(), probabilistic_exposure_probability, rtol=0.05
)
2 changes: 1 addition & 1 deletion caimira/tests/test_infected_population.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def test_infected_population_vectorisation(override_params):
0.51,
defaults['exhalation_rate'],
),
virus=caimira.models.Virus(
virus=caimira.models.SARSCoV2(
viral_load_in_sputum=defaults['viral_load_in_sputum'],
infectious_dose=50.,
viable_to_RNA_ratio = 0.5,
Expand Down

0 comments on commit 12b7b57

Please sign in to comment.