Skip to content

Commit 1103cd0

Browse files
committed
add tests
1 parent 9b41d17 commit 1103cd0

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

test/hawkes_test.jl

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,37 @@ for (i, alg) in enumerate(algs)
131131
@test isapprox(mean(λs), Eλ; atol = 0.01)
132132
@test isapprox(var(λs), Varλ; atol = 0.001)
133133
end
134+
135+
# test stepping Coevolve with continuous integrator and bounded jumps
136+
let
137+
oprob = ODEProblem(f!, u0, tspan, p)
138+
jumps = hawkes_jump(u0, g, h)
139+
jprob = JumpProblem(oprob, Coevolve(), jumps...; dep_graph = g, rng)
140+
@test ((jprob.variable_jumps === nothing) || isempty(jprob.variable_jumps))
141+
sols = Vector{ODESolution}(undef, Nsims)
142+
for n in 1:Nsims
143+
reset_history!(h)
144+
sols[n] = solve(jprob, Tsit5())
145+
end
146+
λs = permutedims(mapreduce((sol) -> empirical_rate(sol), hcat, sols))
147+
@test isapprox(mean(λs), Eλ; atol = 0.01)
148+
@test isapprox(var(λs), Varλ; atol = 0.001)
149+
end
150+
151+
# test disabling bounded jumps and using continuous integrator
152+
let
153+
oprob = ODEProblem(f!, u0, tspan, p)
154+
jumps = hawkes_jump(u0, g, h)
155+
jprob = JumpProblem(oprob, Coevolve(), jumps...; dep_graph = g, rng,
156+
use_vrj_bounds = false)
157+
@test length(jprob.variable_jumps) == 1
158+
sols = Vector{ODESolution}(undef, Nsims)
159+
for n in 1:Nsims
160+
reset_history!(h)
161+
sols[n] = solve(jprob, Tsit5())
162+
end
163+
cols = length(sols[1].u[1].u)
164+
λs = permutedims(mapreduce((sol) -> empirical_rate(sol), hcat, sols))[:, 1:cols]
165+
@test isapprox(mean(λs), Eλ; atol = 0.01)
166+
@test isapprox(var(λs), Varλ; atol = 0.001)
167+
end

0 commit comments

Comments
 (0)