-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sofia Calgaro
committed
Dec 31, 2024
1 parent
c762bcc
commit daf90a3
Showing
3 changed files
with
65 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
using Pkg | ||
Pkg.activate(".") | ||
Pkg.instantiate() | ||
using Random | ||
include("../../src/ZeroNuFit.jl") | ||
using .ZeroNuFit | ||
include("../../main.jl") | ||
include("../../src/utils.jl") | ||
include("../../src/constants.jl") | ||
|
||
@testset "test_norm_exponential" begin | ||
|
||
@info "Testing normalised exponential function (function 'norm_exponential' in src/fitting.jl)" | ||
|
||
# high Rt value | ||
x = 1965.0 | ||
p = (S = 100, αe_all = 0.1, ω = [1.1], 𝛥 = [0.1], B_l200a_all = 2E-4, B_l200a_all_slope = 10) | ||
b_name = :B_l200a_all | ||
fit_range = [[1920.0, 1930.0], [1960.0, 1970.0]] | ||
expo_func = nothing | ||
try | ||
expo_func = ZeroNuFit.norm_exponential(x, p, b_name, fit_range) | ||
catch e | ||
@error "Error in 'norm_exponential' evaluation: $e" | ||
throw(e) | ||
end | ||
|
||
@testset "Check expo_func is valid (high Rt value)" begin | ||
@test !isnothing(expo_func) | ||
end | ||
|
||
expected_value = 0.08506327727340002 | ||
tolerance = 1e-3 | ||
@testset "Check expo_func accuracy (high Rt value)" begin | ||
diff = abs(expo_func - expected_value) | ||
@test diff <= tolerance | ||
end | ||
|
||
# low Rt value | ||
p = (S = 100, αe_all = 0.1, ω = [1.1], 𝛥 = [0.1], B_l200a_all = 2E-4, B_l200a_all_slope = 0.00001) | ||
expo_func = nothing | ||
try | ||
expo_func = ZeroNuFit.norm_exponential(x, p, b_name, fit_range) | ||
catch e | ||
@error "Error in 'norm_exponential' evaluation: $e" | ||
throw(e) | ||
end | ||
|
||
@testset "Check expo_func is valid (low Rt value)" begin | ||
@test !isnothing(expo_func) | ||
end | ||
|
||
expected_value = 0.05000045000202501 | ||
tolerance = 1e-3 | ||
@testset "Check expo_func accuracy (low Rt value)" begin | ||
diff = abs(expo_func - expected_value) | ||
@test diff <= tolerance | ||
end | ||
|
||
end |