Skip to content

Commit 7f344e8

Browse files
author
Arthur Amorim
committed
Added tests for inplace RODESolution interpolation
1 parent 6515424 commit 7f344e8

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "StochasticDiffEq"
22
uuid = "789caeaf-c7a9-5a7d-9973-96adeb23e2a0"
33
authors = ["Chris Rackauckas <[email protected]>"]
4-
version = "6.61.2a"
4+
version = "6.61.2b"
55

66
[deps]
77
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"

test/inplace_interpolation.jl

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using StochasticDiffEq, Test, Random
2+
import SDEProblemLibrary: prob_sde_linear, prob_sde_2Dlinear
3+
Random.seed!(100)
4+
5+
vecarrzero(m::Integer, n) = map(t->zeros(n), 1:m)
6+
7+
tt = 0:0.05:1
8+
ntt = length(tt)
9+
out_VF = zeros(ntt) # Vector{Float64}
10+
out_VVF_1 = vecarrzero(ntt,1) # Vector{Vector{Float64}}
11+
out_VVF_2 = vecarrzero(ntt,2) # Vector{Vector{Float64}}
12+
out_VMF = vecarrzero(ntt, size(prob_sde_2Dlinear.u0)) # Vector{Matrix{Float64}}
13+
14+
15+
@testset verbose=true "SDESolution interpolation" begin
16+
sol_SDE = solve(prob_sde_linear, SRIW1(); dt=1//2^4)
17+
sol_SDE_2D = solve(prob_sde_2Dlinear, SRIW1(); dt=1//2^4)
18+
19+
sol_SDE_interp = sol_SDE(tt)
20+
sol_SDE_2D_interp = sol_SDE_2D(tt)
21+
22+
@testset "1D" begin
23+
@test_throws MethodError sol_SDE(out_VF, tt; idxs=1:1)
24+
@test sol_SDE(out_VF, tt) isa Vector{Float64}
25+
@test sol_SDE(out_VVF_1,tt) isa Vector{Vector{Float64}}
26+
@test sol_SDE_interp.u == out_VF
27+
end
28+
29+
@testset "2D" begin
30+
@test_throws MethodError sol_SDE_2D(out_VF, tt; idxs=3:3)
31+
@test sol_SDE_2D(out_VF, tt; idxs=3) isa Vector{Float64}
32+
@test sol_SDE_2D(out_VVF_1, tt; idxs=3) isa Vector{Vector{Float64}}
33+
@test sol_SDE_2D(out_VVF_1, tt; idxs=3:3) isa Vector{Vector{Float64}}
34+
@test sol_SDE_2D(out_VVF_2, tt; idxs=2:3) isa Vector{Vector{Float64}}
35+
@test sol_SDE_2D(out_VMF, tt) isa Vector{Matrix{Float64}}
36+
@test sol_SDE_2D_interp.u == out_VMF
37+
end
38+
end

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const is_APPVEYOR = Sys.iswindows() && haskey(ENV,"APPVEYOR")
4040
@time @safetestset "Scalar Tests" begin include("scalar_noise.jl") end
4141
@time @safetestset "Stiffness Detection Test" begin include("stiffness_detection_test.jl") end
4242
@time @safetestset "Adaptive SDE Linear Tests" begin include("adaptive/sde_linearadaptive_tests.jl") end
43+
@time @safetestset "Inplace RODESolution Interpolation Tests" begin include("inplace_interpolation.jl") end
4344
end
4445

4546
if GROUP == "All" || GROUP == "Interface3"

0 commit comments

Comments
 (0)