|
| 1 | +using SimpleDiffEq |
| 2 | +using JET |
| 3 | +using DiffEqBase |
| 4 | +using Test |
| 5 | + |
| 6 | +@testset "JET Static Analysis" begin |
| 7 | + # Define test problems |
| 8 | + f_scalar(u, p, t) = 1.01 * u |
| 9 | + u0_scalar = 1.5 |
| 10 | + tspan = (0.0, 1.0) |
| 11 | + prob_scalar = ODEProblem(f_scalar, u0_scalar, tspan) |
| 12 | + |
| 13 | + function f_iip!(du, u, p, t) |
| 14 | + du[1] = 1.01 * u[1] |
| 15 | + du[2] = 2.0 * u[2] |
| 16 | + end |
| 17 | + u0_iip = [1.5, 2.0] |
| 18 | + prob_iip = ODEProblem(f_iip!, u0_iip, tspan) |
| 19 | + |
| 20 | + @testset "SimpleEuler type stability" begin |
| 21 | + # OOP scalar |
| 22 | + integ_oop = DiffEqBase.__init(prob_scalar, SimpleEuler(), dt = 0.1) |
| 23 | + rep = JET.report_opt(DiffEqBase.step!, (typeof(integ_oop),)) |
| 24 | + @test length(JET.get_reports(rep)) == 0 |
| 25 | + |
| 26 | + # IIP array |
| 27 | + integ_iip = DiffEqBase.__init(prob_iip, SimpleEuler(), dt = 0.1) |
| 28 | + rep = JET.report_opt(DiffEqBase.step!, (typeof(integ_iip),)) |
| 29 | + @test length(JET.get_reports(rep)) == 0 |
| 30 | + end |
| 31 | + |
| 32 | + @testset "SimpleRK4 type stability" begin |
| 33 | + # OOP scalar |
| 34 | + integ_oop = DiffEqBase.__init(prob_scalar, SimpleRK4(), dt = 0.1) |
| 35 | + rep = JET.report_opt(DiffEqBase.step!, (typeof(integ_oop),)) |
| 36 | + @test length(JET.get_reports(rep)) == 0 |
| 37 | + |
| 38 | + # IIP array |
| 39 | + integ_iip = DiffEqBase.__init(prob_iip, SimpleRK4(), dt = 0.1) |
| 40 | + rep = JET.report_opt(DiffEqBase.step!, (typeof(integ_iip),)) |
| 41 | + @test length(JET.get_reports(rep)) == 0 |
| 42 | + end |
| 43 | + |
| 44 | + @testset "SimpleTsit5 type stability" begin |
| 45 | + # OOP scalar |
| 46 | + integ_oop = DiffEqBase.__init(prob_scalar, SimpleTsit5(), dt = 0.1) |
| 47 | + rep = JET.report_opt(DiffEqBase.step!, (typeof(integ_oop),)) |
| 48 | + @test length(JET.get_reports(rep)) == 0 |
| 49 | + |
| 50 | + # IIP array |
| 51 | + integ_iip = DiffEqBase.__init(prob_iip, SimpleTsit5(), dt = 0.1) |
| 52 | + rep = JET.report_opt(DiffEqBase.step!, (typeof(integ_iip),)) |
| 53 | + @test length(JET.get_reports(rep)) == 0 |
| 54 | + end |
| 55 | + |
| 56 | + @testset "SimpleATsit5 type stability" begin |
| 57 | + # OOP scalar |
| 58 | + integ_oop = DiffEqBase.__init(prob_scalar, SimpleATsit5(), dt = 0.1) |
| 59 | + rep = JET.report_opt(DiffEqBase.step!, (typeof(integ_oop),)) |
| 60 | + @test length(JET.get_reports(rep)) == 0 |
| 61 | + |
| 62 | + # IIP array |
| 63 | + integ_iip = DiffEqBase.__init(prob_iip, SimpleATsit5(), dt = 0.1) |
| 64 | + rep = JET.report_opt(DiffEqBase.step!, (typeof(integ_iip),)) |
| 65 | + @test length(JET.get_reports(rep)) == 0 |
| 66 | + end |
| 67 | +end |
0 commit comments