Skip to content

Commit

Permalink
rename growth_rate_to_reproductive_ratio -> r_to_R
Browse files Browse the repository at this point in the history
  • Loading branch information
seabbs committed Feb 19, 2024
1 parent 6e7a93f commit 37eb594
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions EpiAware/src/utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion EpiAware/test/predictive_checking/fast_approx_for_r.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions EpiAware/test/test_utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,21 +81,21 @@ 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

#Test MethodError when w is not a vector
@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
Expand Down

0 comments on commit 37eb594

Please sign in to comment.