-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathdiscrete.jl
32 lines (26 loc) · 1.02 KB
/
discrete.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using DynamicalSystemsBase, Test
include("test_system_function.jl")
# Creation of Henon map
henon_rule(x, p, n) = SVector{2}(1.0 - p[1]*x[1]^2 + x[2], p[2]*x[1])
function henon_rule_iip(dx, x, p, n)
dx .= henon_rule(x, p, n)
return
end
u0 = zeros(2)
p0 = [1.4, 0.3]
henon_oop = DeterministicIteratedMap(henon_rule, u0, p0)
henon_iip = DeterministicIteratedMap(henon_rule_iip, copy(u0), p0)
@testset "Henon IIP=$(iip)" for (henon, iip) in zip((henon_oop, henon_iip), (false, true))
@test dynamic_rule(henon) == (iip ? henon_rule_iip : henon_rule)
test_dynamical_system(henon, u0, p0; idt = true, iip)
end
@testset "API" begin # also test API functions that are generic
reinit!(henon_oop)
set_parameters!(henon_oop, [2 => 1.1])
@test current_parameter(henon_oop, 2) == 1.1
set_parameters!(henon_oop, [0.3, 1.4])
@test current_parameter(henon_oop, 2) == 1.4
@test current_parameter(henon_oop, 1) == 0.3
set_parameters!(henon_oop, Dict(2 => 1.1))
@test current_parameter(henon_oop, 2) == 1.1
end