Skip to content

Commit

Permalink
brute force chances for TestItemRunner
Browse files Browse the repository at this point in the history
  • Loading branch information
seabbs committed Feb 12, 2024
1 parent 8bd7d7d commit a908adc
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 23 deletions.
10 changes: 2 additions & 8 deletions EpiAware/test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
using Test
using EpiAware
using Distributions
using LinearAlgebra
using Turing, DynamicPPL
using TestItemRunner

include("test_utilities.jl")
include("test_epimodel.jl")
include("test_latent-processes.jl")
@run_package_tests
6 changes: 3 additions & 3 deletions EpiAware/test/test_epimodel.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

@testset "EpiModel constructor" begin
@testitem "EpiModel constructor" begin
gen_int = [0.2, 0.3, 0.5]
delay_int = [0.1, 0.4, 0.5]
cluster_coeff = 0.8
Expand All @@ -19,7 +19,7 @@
@test size(model.delay_kernel) == (time_horizon, time_horizon)
end

@testset "EpiModel constructor" begin
@testitem "EpiModel constructor" begin
gen_int = [0.2, 0.3, 0.5]
delay_int = [0.1, 0.4, 0.5]
cluster_coeff = 0.8
Expand All @@ -39,7 +39,7 @@ end
@test size(model.delay_kernel) == (time_horizon, time_horizon)
end

@testset "EpiModel function" begin
@testitem "EpiModel function" begin
recent_incidence = [10, 20, 30]
Rt = 1.5

Expand Down
4 changes: 2 additions & 2 deletions EpiAware/test/test_latent-processes.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@


@testset "Testing random_walk function" begin
@testitem "Testing random_walk function" begin
# Test case 1: Testing against theoretical properties
@testset "Test case 1" begin
@testitem "Test case 1" begin
n = 5
model = random_walk(n)
fixed_model = fix(model, (σ²_RW = 1.0,)) #Fixing the standard deviation of the random walk process
Expand Down
20 changes: 10 additions & 10 deletions EpiAware/test/test_utilities.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@testset "Testing scan function with addition" begin
@testitem "Testing scan function with addition" begin
# Test case 1: Testing with addition function
function add(a, b)
return a + b, a + b
Expand All @@ -12,7 +12,7 @@
@test carry == expected_carry
end

@testset "Testing scan function with multiplication" begin
@testitem "Testing scan function with multiplication" begin
# Test case 2: Testing with multiplication function
function multiply(a, b)
return a * b, a * b
Expand All @@ -27,26 +27,26 @@ end
@test carry == expected_carry
end

@testset "Testing create_discrete_pmf function" begin
@testitem "Testing create_discrete_pmf function" begin
# Test case 1: Testing with a non-negative distribution
@testset "Test case 1" begin
@testitem "Test case 1" begin
dist = Normal()
@test_throws AssertionError create_discrete_pmf(dist, Δd = 1.0, D = 3.0)
end

# Test case 2: Testing with Δd = 0.0
@testset "Test case 2" begin
@testitem "Test case 2" begin
dist = Exponential(1.0)
@test_throws AssertionError create_discrete_pmf(dist, Δd = 0.0, D = 3.0)
end

@testset "Test case 3" begin
@testitem "Test case 3" begin
dist = Exponential(1.0)
@test_throws AssertionError create_discrete_pmf(dist, Δd = 3.0, D = 1.0)
end

# Test case 4: Testing output against expected PMF
@testset "Test case 4" begin
@testitem "Test case 4" begin
dist = Exponential(1.0)
expected_pmf = [(exp(-(t - 1)) - exp(-t)) / (1 - exp(-5)) for t = 1:5]
pmf = create_discrete_pmf(dist, Δd = 1.0, D = 5.0)
Expand All @@ -55,9 +55,9 @@ end

end

@testset "Testing growth_rate_to_reproductive_ratio function" begin
@testitem "Testing growth_rate_to_reproductive_ratio function" begin
#Test that zero exp growth rate imples R0 = 1
@testset "Test case 1" begin
@testitem "Test case 1" begin
r = 0
w = ones(5) |> x -> x ./ sum(x)
expected_ratio = 1
Expand All @@ -66,7 +66,7 @@ end
end

#Test MethodError when w is not a vector
@testset "Test case 2" begin
@testitem "Test case 2" begin
r = 0
w = 1
@test_throws MethodError growth_rate_to_reproductive_ratio(r, w)
Expand Down

0 comments on commit a908adc

Please sign in to comment.