1
- using OrdinaryDiffEqFunctionMap
2
- using OrdinaryDiffEqCore
1
+ import OrdinaryDiffEqFunctionMap
2
+ import OrdinaryDiffEqCore
3
3
using Test
4
4
using SciMLBase
5
+ using SciMLBase: solve, init, DiscreteProblem
6
+
7
+ const FunctionMap = OrdinaryDiffEqFunctionMap. FunctionMap
8
+
9
+ # Helper functions to check algorithm properties regardless of module context
10
+ is_functionmap (alg) = typeof (alg). name. name == :FunctionMap
11
+ function get_scale_by_time (alg)
12
+ # Access the type parameter directly since it's FunctionMap{scale_by_time}
13
+ T = typeof (alg)
14
+ # The parameter is stored as a type parameter
15
+ return T. parameters[1 ]
16
+ end
5
17
6
18
@testset " DiscreteProblem Default Algorithm" begin
7
19
# Test scalar DiscreteProblem
@@ -11,14 +23,14 @@ using SciMLBase
11
23
@testset " Scalar DiscreteProblem" begin
12
24
# Test solve without explicit algorithm
13
25
sol = solve (prob_scalar)
14
- @test typeof (sol. alg). name . name == :FunctionMap
15
- @test sol. alg == FunctionMap ()
26
+ @test is_functionmap (sol. alg)
27
+ @test get_scale_by_time ( sol. alg) == false
16
28
@test length (sol. u) > 1
17
29
18
30
# Test init without explicit algorithm
19
31
integrator = init (prob_scalar)
20
- @test typeof (integrator. alg). name . name == :FunctionMap
21
- @test integrator. alg == FunctionMap ()
32
+ @test is_functionmap (integrator. alg)
33
+ @test get_scale_by_time ( integrator. alg) == false
22
34
end
23
35
24
36
# Test array DiscreteProblem
@@ -31,29 +43,33 @@ using SciMLBase
31
43
@testset " Array DiscreteProblem" begin
32
44
# Test solve without explicit algorithm
33
45
sol = solve (prob_array)
34
- @test typeof (sol. alg). name . name == :FunctionMap
35
- @test sol. alg == FunctionMap ()
46
+ @test is_functionmap (sol. alg)
47
+ @test get_scale_by_time ( sol. alg) == false
36
48
@test length (sol. u) > 1
37
49
38
50
# Test init without explicit algorithm
39
51
integrator = init (prob_array)
40
- @test typeof (integrator. alg). name . name == :FunctionMap
41
- @test integrator. alg == FunctionMap ()
52
+ @test is_functionmap (integrator. alg)
53
+ @test get_scale_by_time ( integrator. alg) == false
42
54
end
43
55
44
56
# Test that explicit algorithm specification still works
45
57
@testset " Explicit FunctionMap specification" begin
46
58
sol1 = solve (prob_scalar, FunctionMap ())
47
- @test sol1. alg == FunctionMap (scale_by_time= false )
59
+ @test is_functionmap (sol1. alg)
60
+ @test get_scale_by_time (sol1. alg) == false
48
61
49
62
sol2 = solve (prob_scalar, FunctionMap (scale_by_time= true ), dt= 0.1 )
50
- @test sol2. alg == FunctionMap (scale_by_time= true )
63
+ @test is_functionmap (sol2. alg)
64
+ @test get_scale_by_time (sol2. alg) == true
51
65
52
66
integrator1 = init (prob_scalar, FunctionMap ())
53
- @test integrator1. alg == FunctionMap (scale_by_time= false )
67
+ @test is_functionmap (integrator1. alg)
68
+ @test get_scale_by_time (integrator1. alg) == false
54
69
55
70
integrator2 = init (prob_scalar, FunctionMap (scale_by_time= true ), dt= 0.1 )
56
- @test integrator2. alg == FunctionMap (scale_by_time= true )
71
+ @test is_functionmap (integrator2. alg)
72
+ @test get_scale_by_time (integrator2. alg) == true
57
73
end
58
74
59
75
# Test that the default behaves correctly with different problem types
@@ -66,10 +82,10 @@ using SciMLBase
66
82
prob_int = DiscreteProblem (henon_map!, [0.5 , 0.5 ], (0 , 10 ))
67
83
68
84
sol = solve (prob_int)
69
- @test typeof (sol. alg). name . name == :FunctionMap
85
+ @test is_functionmap (sol. alg)
70
86
@test eltype (sol. t) <: Integer
71
87
72
88
integrator = init (prob_int)
73
- @test typeof (integrator. alg). name . name == :FunctionMap
89
+ @test is_functionmap (integrator. alg)
74
90
end
75
91
end
0 commit comments