From 736929cc8b7d148e38c01c6e2955afa9f655972d Mon Sep 17 00:00:00 2001 From: "George G. Vega Yon" Date: Tue, 28 May 2024 10:38:57 -0600 Subject: [PATCH 1/3] Renaming sample_infections to compute_future_infections --- model/src/pyrenew/latent/__init__.py | 8 ++++---- model/src/pyrenew/latent/infection_functions.py | 12 +++++++----- model/src/pyrenew/latent/infections.py | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/model/src/pyrenew/latent/__init__.py b/model/src/pyrenew/latent/__init__.py index ecbad7a4..22253b23 100644 --- a/model/src/pyrenew/latent/__init__.py +++ b/model/src/pyrenew/latent/__init__.py @@ -8,9 +8,9 @@ ) from pyrenew.latent.i0 import Infections0 from pyrenew.latent.infection_functions import ( + compute_future_infections_rt, + compute_future_infections_with_feedback, logistic_susceptibility_adjustment, - sample_infections_rt, - sample_infections_with_feedback, ) from pyrenew.latent.infections import Infections @@ -19,7 +19,7 @@ "InfectHospRate", "Infections", "logistic_susceptibility_adjustment", - "sample_infections_rt", - "sample_infections_with_feedback", + "compute_future_infections_rt", + "compute_future_infections_with_feedback", "Infections0", ] diff --git a/model/src/pyrenew/latent/infection_functions.py b/model/src/pyrenew/latent/infection_functions.py index 54523806..3448c281 100755 --- a/model/src/pyrenew/latent/infection_functions.py +++ b/model/src/pyrenew/latent/infection_functions.py @@ -9,11 +9,13 @@ from pyrenew.convolve import new_convolve_scanner, new_double_scanner -def sample_infections_rt( - I0: ArrayLike, Rt: ArrayLike, reversed_generation_interval_pmf: ArrayLike +def compute_future_infections_rt( + I0: ArrayLike, + Rt: ArrayLike, + reversed_generation_interval_pmf: ArrayLike, ) -> ArrayLike: """ - Sample infections according to a + Generate infections according to a renewal process with a time-varying reproduction number R(t) @@ -84,7 +86,7 @@ def logistic_susceptibility_adjustment( return n_population * frac_susceptible * approx_frac_infected -def sample_infections_with_feedback( +def compute_future_infections_with_feedback( I0: ArrayLike, Rt_raw: ArrayLike, infection_feedback_strength: ArrayLike, @@ -92,7 +94,7 @@ def sample_infections_with_feedback( infection_feedback_pmf: ArrayLike, ) -> tuple: """ - Sample infections according to + Generate infections according to a renewal process with infection feedback (generalizing Asher 2018: https://doi.org/10.1016/j.epidem.2017.02.009) diff --git a/model/src/pyrenew/latent/infections.py b/model/src/pyrenew/latent/infections.py index 30f2bc71..7b029215 100644 --- a/model/src/pyrenew/latent/infections.py +++ b/model/src/pyrenew/latent/infections.py @@ -107,7 +107,7 @@ def sample( n_lead = gen_int_rev.size - 1 I0_vec = jnp.hstack([jnp.zeros(n_lead), I0]) - all_infections = inf.sample_infections_rt( + all_infections = inf.compute_future_infections_rt( I0=I0_vec, Rt=Rt, reversed_generation_interval_pmf=gen_int_rev, From 4be3058741ab2650eab92e97acc38f1d13ddf3d9 Mon Sep 17 00:00:00 2001 From: "George G. Vega Yon" Date: Tue, 28 May 2024 12:23:24 -0600 Subject: [PATCH 2/3] Renaming functions --- model/src/pyrenew/latent/__init__.py | 8 ++++---- model/src/pyrenew/latent/infection_functions.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/model/src/pyrenew/latent/__init__.py b/model/src/pyrenew/latent/__init__.py index 22253b23..ccb85f1f 100644 --- a/model/src/pyrenew/latent/__init__.py +++ b/model/src/pyrenew/latent/__init__.py @@ -8,8 +8,8 @@ ) from pyrenew.latent.i0 import Infections0 from pyrenew.latent.infection_functions import ( - compute_future_infections_rt, - compute_future_infections_with_feedback, + compute_infections_from_rt, + compute_infections_from_rt_with_feedback, logistic_susceptibility_adjustment, ) from pyrenew.latent.infections import Infections @@ -19,7 +19,7 @@ "InfectHospRate", "Infections", "logistic_susceptibility_adjustment", - "compute_future_infections_rt", - "compute_future_infections_with_feedback", + "compute_infections_from_rt", + "compute_infections_from_rt_with_feedback", "Infections0", ] diff --git a/model/src/pyrenew/latent/infection_functions.py b/model/src/pyrenew/latent/infection_functions.py index 3448c281..7ce8a931 100755 --- a/model/src/pyrenew/latent/infection_functions.py +++ b/model/src/pyrenew/latent/infection_functions.py @@ -9,7 +9,7 @@ from pyrenew.convolve import new_convolve_scanner, new_double_scanner -def compute_future_infections_rt( +def compute_infections_from_rt( I0: ArrayLike, Rt: ArrayLike, reversed_generation_interval_pmf: ArrayLike, @@ -86,7 +86,7 @@ def logistic_susceptibility_adjustment( return n_population * frac_susceptible * approx_frac_infected -def compute_future_infections_with_feedback( +def compute_infections_from_rt_with_feedback( I0: ArrayLike, Rt_raw: ArrayLike, infection_feedback_strength: ArrayLike, From 72fec944d602fdab6f148a8cb8b2d46394d6ad38 Mon Sep 17 00:00:00 2001 From: "George G. Vega Yon" Date: Tue, 28 May 2024 14:56:00 -0600 Subject: [PATCH 3/3] Last replace --- model/src/pyrenew/latent/infections.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model/src/pyrenew/latent/infections.py b/model/src/pyrenew/latent/infections.py index 7b029215..5edfbb99 100644 --- a/model/src/pyrenew/latent/infections.py +++ b/model/src/pyrenew/latent/infections.py @@ -107,7 +107,7 @@ def sample( n_lead = gen_int_rev.size - 1 I0_vec = jnp.hstack([jnp.zeros(n_lead), I0]) - all_infections = inf.compute_future_infections_rt( + all_infections = inf.compute_infections_from_rt( I0=I0_vec, Rt=Rt, reversed_generation_interval_pmf=gen_int_rev,