|
1 | 1 | @testitem "Type Stability" begin |
2 | | - using LinearAlgebra, BoundaryValueDiffEq, OrdinaryDiffEqTsit5 |
| 2 | + using LinearAlgebra, BoundaryValueDiffEq, OrdinaryDiffEqTsit5, SciMLBase |
3 | 3 |
|
4 | 4 | f(u, p, t) = [p[1] * u[1] - p[2] * u[1] * u[2], p[3] * u[1] * u[2] - p[4] * u[2]] |
5 | 5 | function f!(du, u, p, t) |
|
24 | 24 |
|
25 | 25 | jac_alg = BVPJacobianAlgorithm(AutoForwardDiff(; chunksize = 2)) |
26 | 26 |
|
| 27 | + # BVProblem constructor type stability (issue #454) |
| 28 | + # Explicit {iip} constructors should be type-stable |
| 29 | + @testset "BVProblem Constructor" begin |
| 30 | + @inferred BVProblem{true}(f!, bc!, u0, tspan, p) |
| 31 | + @inferred BVProblem{false}(f, bc, u0, tspan, p) |
| 32 | + |
| 33 | + # __init should be type-stable with properly typed problems |
| 34 | + prob_iip = BVProblem{true}(f!, bc!, u0, tspan, p) |
| 35 | + @inferred SciMLBase.__init(prob_iip, MIRK5(; jac_alg); dt = 0.2) |
| 36 | + end |
| 37 | + |
27 | 38 | # Multi-Point BVP |
| 39 | + # nlls is properly inferred as false for StandardBVProblem without bcresid_prototype |
28 | 40 | @testset "Multi-Point BVP" begin |
29 | | - mpbvp_iip = BVProblem(f!, bc!, u0, tspan, p; nlls = Val(false)) |
30 | | - mpbvp_oop = BVProblem(f, bc, u0, tspan, p; nlls = Val(false)) |
| 41 | + mpbvp_iip = BVProblem(f!, bc!, u0, tspan, p) |
| 42 | + mpbvp_oop = BVProblem(f, bc, u0, tspan, p) |
31 | 43 |
|
32 | 44 | # Shooting methods have deep type instability from NonlinearSolve/OrdinaryDiffEq |
33 | 45 | # that requires further investigation. The solvers work correctly but return type |
|
0 commit comments