From 1803d4e919ee826304deecae9cd670282f5ca549 Mon Sep 17 00:00:00 2001 From: Luis Aleixo Date: Mon, 26 Jul 2021 14:16:51 +0200 Subject: [PATCH] mypy errors - added some dummy variables to test_exposure_model.py --- cara/tests/models/test_exposure_model.py | 32 +++++++++++++++--------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/cara/tests/models/test_exposure_model.py b/cara/tests/models/test_exposure_model.py index e3e35e87..1b06c23f 100644 --- a/cara/tests/models/test_exposure_model.py +++ b/cara/tests/models/test_exposure_model.py @@ -17,10 +17,6 @@ class KnownConcentrations(models.ConcentrationModel): which therefore doesn't need other components. Useful for testing. """ - #def __init__(self, concentration_function: typing.Callable) -> None: - # self._func = concentration_function - - concentration_function: typing.Callable def infectious_virus_removal_rate(self, time: float) -> models._VectorisedFloat: @@ -58,23 +54,35 @@ populations = [ models.Activity(np.array([0.51,0.57]), 0.57), ), ] +dummyRoom = models.Room(50, 0.5) +dummyVentilation = models._VentilationBase() +dummyInfPopulation = models.InfectedPopulation( + number=1, + presence=halftime, + mask=models.Mask.types['Type I'], + activity=models.Activity.types['Standing'], + virus=models.Virus.types['SARS_CoV_2_B117'], + expiration=models.Expiration.types['Talking'] +) +def known_concentrations(func): + return KnownConcentrations(dummyRoom, dummyVentilation, dummyInfPopulation, func) @pytest.mark.parametrize( "population, cm, f_dep, expected_exposure, expected_cumulated_exposure, expected_probability",[ - [populations[1], KnownConcentrations(None, None, None, lambda t: 1.2), 1., + [populations[1], known_concentrations(lambda t: 1.2), 1., np.array([14.4, 14.4]), np.array([3.44736/0.6, 3.20112/0.6]), np.array([99.6803184113, 99.5181053773])], - [populations[2], KnownConcentrations(None, None, None, lambda t: 1.2), 1., + [populations[2], known_concentrations(lambda t: 1.2), 1., np.array([14.4, 14.4]), np.array([2.2032/0.6, 2.4624/0.6]), np.array([97.4574432074, 98.3493482895])], - [populations[0], KnownConcentrations(None, None, None,lambda t: np.array([1.2, 2.4])), 1., + [populations[0], known_concentrations(lambda t: np.array([1.2, 2.4])), 1., np.array([14.4, 28.8]), np.array([2.4624/0.6, 4.9248/0.6]), np.array([98.3493482895, 99.9727534893])], - [populations[1], KnownConcentrations(None, None, None,lambda t: np.array([1.2, 2.4])), 1., + [populations[1], known_concentrations(lambda t: np.array([1.2, 2.4])), 1., np.array([14.4, 28.8]), np.array([3.44736/0.6, 6.40224/0.6]), np.array([99.6803184113, 99.9976777757])], - [populations[0], KnownConcentrations(None, None, None,lambda t: 2.4), np.array([0.5, 1.]), + [populations[0], known_concentrations(lambda t: 2.4), np.array([0.5, 1.]), 28.8, np.array([4.104, 8.208]), np.array([98.3493482895, 99.9727534893])], ]) def test_exposure_model_ndarray(population, cm, f_dep, @@ -100,7 +108,7 @@ def test_exposure_model_ndarray(population, cm, f_dep, @pytest.mark.parametrize("population", populations) def test_exposure_model_ndarray_and_float_mix(population): - cm = KnownConcentrations(None, None, None, lambda t: 0 if np.floor(t) % 2 else np.array([1.2, 1.2])) + cm = known_concentrations(lambda t: 0 if np.floor(t) % 2 else np.array([1.2, 1.2])) model = ExposureModel(cm, population) expected_exposure = np.array([14.4, 14.4]) @@ -114,8 +122,8 @@ def test_exposure_model_ndarray_and_float_mix(population): @pytest.mark.parametrize("population", populations) def test_exposure_model_compare_scalar_vector(population): - cm_scalar = KnownConcentrations(None, None, None,lambda t: 1.2) - cm_array = KnownConcentrations(None, None, None, lambda t: np.array([1.2, 1.2])) + cm_scalar = known_concentrations(lambda t: 1.2) + cm_array = known_concentrations(lambda t: np.array([1.2, 1.2])) model_scalar = ExposureModel(cm_scalar, population) model_array = ExposureModel(cm_array, population) expected_exposure = 14.4