Skip to content

Commit 4d0f95e

Browse files
committed
tests
1 parent 47da9ea commit 4d0f95e

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

test/jacobian.jl

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using DynamicalSystemsBase, Test
2+
3+
function oop(u, p, t)
4+
return p[1] * SVector(u[1], -u[2])
5+
end
6+
7+
function iip(du, u, p, t)
8+
du .= oop(u, p, t)
9+
return nothing
10+
end
11+
12+
#%%
13+
@testset "IDT=$(IDT), IIP=$(IIP)" for IDT in (true, false), IIP in (false, true)
14+
SystemType = IDT ? DeterministicIteratedMap : CoupledODEs
15+
rule = IIP ? iip : oop
16+
p = 3.0
17+
u0 = [1.0, 1.0]
18+
result = [p 0.0; 0.0 -p]
19+
20+
ds = SystemType(rule, u0, p)
21+
J0 = zeros(dimension(ds), dimension(ds))
22+
J = jacobian(ds)
23+
if IIP
24+
J(J0, current_state(ds), current_parameters(ds), 0.0)
25+
@test J0 == result
26+
else
27+
@test J(current_state(ds), current_parameters(ds), 0.0) == result
28+
end
29+
end

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ testfile(file, testname=defaultname(file)) = @testset "$testname" begin; include
1616
testfile("successful_step.jl")
1717
testfile("mtk_integration.jl")
1818
testfile("trajectory.jl")
19+
testfile("jacobian.jl")
1920
end

0 commit comments

Comments
 (0)