Skip to content

Commit

Permalink
Handle warnings in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
frankschae committed Aug 5, 2022
1 parent 9320b26 commit 2d54a3b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 18 deletions.
27 changes: 16 additions & 11 deletions src/noise_interfaces/box_wedge_tail_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,10 @@ end
# sampling from boxes
function sample_box(W::BoxWedgeTail, Boxes::AbstractBoxGeneration)
indx = rand(W.rng, Boxes.dist)
# boxes store r, a, Δr, Δa
# boxes store r, a, Δr, Δa
ri, ai, Δr, Δa = Boxes.boxes[indx]
DU = Distributions.Product(Distributions.Uniform.([ri, ai], [ri + Δr, ai + Δa]))
DU = Distributions.product_distribution(Distributions.Uniform.([ri, ai],
[ri + Δr, ai + Δa]))

r, a = rand(W.rng, DU)
return r, a
Expand Down Expand Up @@ -458,8 +459,12 @@ function sample_wedge(W::BoxWedgeTail, wedges::Wedges)
indx = rand(W.rng, wedges.dist)
# wedges store f̃ij, hij, ϵijmin, ϵijmax, r, a, Δr
f̃ij, hij, ϵijmin, ϵijmax, ri, ai = wedges.boxes[indx]
DU = Distributions.Product(Distributions.Uniform.([ri, ai, hij],
[ri + W.Δr, ai + W.Δa, f̃ij]))
DU = Distributions.product_distribution(Distributions.Uniform.([ri, ai, hij],
[
ri + W.Δr,
ai + W.Δa,
f̃ij,
]))
if W.sqeezing
fij, fij2, fij3, fij4 = wedges.fvalues[indx]
while true
Expand Down Expand Up @@ -550,7 +555,7 @@ struct Tail3{pType, distType, pdfType, cType} <: AbstractTail
2 / pi)), aM,
8 * one(aM))

dist = Distributions.Product([dist1, dist2])
dist = Distributions.product_distribution([dist1, dist2])

c = convert(typeof(rM), 2.6)

Expand All @@ -572,7 +577,7 @@ struct Tail4{pType, distType, pdfType, cType} <: AbstractTail
1 / pi)), aM,
6 * one(aM))

dist = Distributions.Product([dist1, dist2])
dist = Distributions.product_distribution([dist1, dist2])

c = convert(typeof(rM), 2.6)

Expand All @@ -594,7 +599,7 @@ struct Tail5{pType, distType, pdfType, cType} <: AbstractTail
1 / 2.8)), aM,
6 * one(aM))

dist = Distributions.Product([dist1, dist2])
dist = Distributions.product_distribution([dist1, dist2])

c = convert(typeof(rM), 2.8)

Expand All @@ -616,7 +621,7 @@ struct Tail6{pType, distType, pdfType, cType} <: AbstractTail
1 / 2.6)), aM,
6 * one(aM))

dist = Distributions.Product([dist1, dist2])
dist = Distributions.product_distribution([dist1, dist2])

c = convert(typeof(rM), 3.0)

Expand All @@ -638,7 +643,7 @@ struct Tail7{pType, distType, pdfType, cType} <: AbstractTail
1 / 2.4)), aM,
6 * one(aM))

dist = Distributions.Product([dist1, dist2])
dist = Distributions.product_distribution([dist1, dist2])

c = convert(typeof(rM), 3.2)

Expand All @@ -660,7 +665,7 @@ struct Tail8{pType, distType, pdfType, cType} <: AbstractTail
1 / 2.4)),
6 * one(aM), 8 * one(aM))

dist = Distributions.Product([dist1, dist2])
dist = Distributions.product_distribution([dist1, dist2])

c = convert(typeof(rM), 4.2)

Expand All @@ -682,7 +687,7 @@ struct Tail9{pType, distType, pdfType, cType} <: AbstractTail
2 / pi)),
8 * one(aM), 10 * one(aM))

dist = Distributions.Product([dist1, dist2])
dist = Distributions.product_distribution([dist1, dist2])

c = convert(typeof(rM), 2.4)

Expand Down
20 changes: 13 additions & 7 deletions test/sde_adaptivedistribution_tests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
@testset "SDE Adaptive Distribution Tests" begin
using StochasticDiffEq, StatsBase, Distributions, HypothesisTests
using Random, DiffEqProblemLibrary
using Random
using DiffEqProblemLibrary.SDEProblemLibrary
# load problems
SDEProblemLibrary.importsdeproblems()

prob = prob_sde_linear
Random.seed!(200)
Expand All @@ -12,8 +15,9 @@
for j in 1:M
Wends = Vector{Float64}(undef, N)
for i in 1:N
sol = solve(prob, SRI(), dt = 1 / 2^(4), abstol = 1e-2, reltol = 0,
adaptivealg = :RSwM1)
W = WienerProcess(0.0, 0.0, 0.0, rswm = RSWM(adaptivealg = :RSwM1))
_prob = remake(prob, noise = W)
sol = solve(_prob, SRI(), dt = 1 / 2^(4), abstol = 1e-2, reltol = 0)
Wends[i] = sol.W.W[end]
end
kssol = ApproximateOneSampleKSTest(Wends / sqrt(T), Normal())
Expand All @@ -25,8 +29,9 @@
for j in 1:M
Wends = Vector{Float64}(undef, N)
for i in 1:N
sol = solve(prob, SRI(), dt = 1 / 2^(4), abstol = 1e-2, reltol = 0,
adaptivealg = :RSwM2)
W = WienerProcess(0.0, 0.0, 0.0, rswm = RSWM(adaptivealg = :RSwM2))
_prob = remake(prob, noise = W)
sol = solve(_prob, SRI(), dt = 1 / 2^(4), abstol = 1e-2, reltol = 0)
Wends[i] = sol.W.W[end]
end
kssol = ApproximateOneSampleKSTest(Wends / sqrt(T), Normal())
Expand All @@ -38,8 +43,9 @@
for j in 1:M
Wends = Vector{Float64}(undef, N)
for i in 1:N
sol = solve(prob, SRI(), dt = 1 / 2^(4), abstol = 1e-2, reltol = 0,
adaptivealg = :RSwM3)
W = WienerProcess(0.0, 0.0, 0.0, rswm = RSWM(adaptivealg = :RSwM3))
_prob = remake(prob, noise = W)
sol = solve(_prob, SRI(), dt = 1 / 2^(4), abstol = 1e-2, reltol = 0)
Wends[i] = sol.W.W[end]
end
kssol = ApproximateOneSampleKSTest(Wends / sqrt(T), Normal())
Expand Down

0 comments on commit 2d54a3b

Please sign in to comment.