From 37eb594eeaf339f0811cd2be3c432371e537d338 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 19 Feb 2024 17:48:28 +0000 Subject: [PATCH] rename growth_rate_to_reproductive_ratio -> r_to_R --- EpiAware/src/utilities.jl | 4 ++-- EpiAware/test/predictive_checking/fast_approx_for_r.jl | 2 +- EpiAware/test/test_utilities.jl | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/EpiAware/src/utilities.jl b/EpiAware/src/utilities.jl index 9388b87e1..6090a81e4 100644 --- a/EpiAware/src/utilities.jl +++ b/EpiAware/src/utilities.jl @@ -173,7 +173,7 @@ end """ - growth_rate_to_reproductive_ratio(r, w) + r_to_R(r, w) Compute the reproductive ratio given exponential growth rate `r` and discretized generation interval `w`. @@ -185,7 +185,7 @@ Compute the reproductive ratio given exponential growth rate `r` # Returns - The reproductive ratio. """ -function growth_rate_to_reproductive_ratio(r, w::AbstractVector) +function r_to_R(r, w::AbstractVector) return 1 / neg_MGF(r, w::AbstractVector) end diff --git a/EpiAware/test/predictive_checking/fast_approx_for_r.jl b/EpiAware/test/predictive_checking/fast_approx_for_r.jl index 9374970e8..2646065ef 100644 --- a/EpiAware/test/predictive_checking/fast_approx_for_r.jl +++ b/EpiAware/test/predictive_checking/fast_approx_for_r.jl @@ -59,7 +59,7 @@ doubling_times = [1.0, 3.5, 7.0, 14.0] errors = mapreduce(hcat, doubling_times) do T_2 true_r = log(2) / T_2 # 7 day doubling time - R0 = EpiAware.growth_rate_to_reproductive_ratio(true_r, w) + R0 = EpiAware.r_to_R(true_r, w) return map(idxs) do ns @time r = EpiAware.R_to_r(R0, w, newton_steps = ns) diff --git a/EpiAware/test/test_utilities.jl b/EpiAware/test/test_utilities.jl index ab66dec1c..1f36b2f2b 100644 --- a/EpiAware/test/test_utilities.jl +++ b/EpiAware/test/test_utilities.jl @@ -81,13 +81,13 @@ end end -@testitem "Testing growth_rate_to_reproductive_ratio function" begin +@testitem "Testing r_to_R function" begin #Test that zero exp growth rate imples R0 = 1 @testset "Test case 1" begin r = 0 w = ones(5) |> x -> x ./ sum(x) expected_ratio = 1 - ratio = EpiAware.growth_rate_to_reproductive_ratio(r, w) + ratio = EpiAware.r_to_R(r, w) @test ratio ≈ expected_ratio atol = 1e-15 end @@ -95,7 +95,7 @@ end @testset "Test case 2" begin r = 0 w = 1 - @test_throws MethodError EpiAware.growth_rate_to_reproductive_ratio(r, w) + @test_throws MethodError EpiAware.r_to_R(r, w) end end