Skip to content

Commit e15b181

Browse files
Merge pull request #455 from ChrisRackauckas-Claude/fix/type-stability-454
Fix type instability in solve pathway (#454)
2 parents cd89ddb + a893ce8 commit e15b181

8 files changed

Lines changed: 22 additions & 10 deletions

File tree

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Random = "1.10"
6060
ReTestItems = "1.29"
6161
RecursiveArrayTools = "3.31.2"
6262
Reexport = "1.2"
63-
SciMLBase = "2.138.0"
63+
SciMLBase = "2.152.1"
6464
Sparspak = "0.3.11"
6565
StaticArrays = "1.9.8"
6666
Test = "1.10"

lib/BoundaryValueDiffEqAscher/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Random = "1.10"
3636
ReTestItems = "1.23.1"
3737
RecursiveArrayTools = "3.27.0"
3838
Reexport = "1.2"
39-
SciMLBase = "2.130.0"
39+
SciMLBase = "2.152.1"
4040
Setfield = "1.1.1"
4141
StaticArrays = "1.9.8"
4242
Test = "1.10"

lib/BoundaryValueDiffEqCore/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ OptimizationBase = "3.2.0, 4, 5"
4747
PreallocationTools = "0.4, 1"
4848
RecursiveArrayTools = "3.27.0"
4949
Reexport = "1.2"
50-
SciMLBase = "2.138.0"
50+
SciMLBase = "2.152.1"
5151
SciMLLogging = "1.8.0"
5252
SciMLStructures = "1.7.0"
5353
Setfield = "1"

lib/BoundaryValueDiffEqFIRK/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Random = "1.10"
5353
ReTestItems = "1.23.1"
5454
RecursiveArrayTools = "3.27.0"
5555
Reexport = "1.2"
56-
SciMLBase = "2.138.0"
56+
SciMLBase = "2.152.1"
5757
SciMLStructures = "1.7.0"
5858
Setfield = "1.1.1"
5959
SparseArrays = "1.10"

lib/BoundaryValueDiffEqMIRK/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Random = "1.10"
5353
ReTestItems = "1.23.1"
5454
RecursiveArrayTools = "3.27.0"
5555
Reexport = "1.2"
56-
SciMLBase = "2.138.0"
56+
SciMLBase = "2.152.1"
5757
SciMLStructures = "1.7.0"
5858
Setfield = "1.1.1"
5959
SparseArrays = "1.10"

lib/BoundaryValueDiffEqMIRKN/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Random = "1.10"
4848
ReTestItems = "1.23.1"
4949
RecursiveArrayTools = "3.27.0"
5050
Reexport = "1.2"
51-
SciMLBase = "2.130.0"
51+
SciMLBase = "2.152.1"
5252
Setfield = "1.1.1"
5353
SparseArrays = "1.10"
5454
StaticArrays = "1.9.8"

lib/BoundaryValueDiffEqShooting/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Random = "1.10"
5151
ReTestItems = "1.23.1"
5252
RecursiveArrayTools = "3.27.0"
5353
Reexport = "1.2"
54-
SciMLBase = "2.130.0"
54+
SciMLBase = "2.152.1"
5555
Setfield = "1.1.1"
5656
SparseArrays = "1.10"
5757
StaticArrays = "1.9.8"

test/misc/type_stability_tests.jl

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@testitem "Type Stability" begin
2-
using LinearAlgebra, BoundaryValueDiffEq, OrdinaryDiffEqTsit5
2+
using LinearAlgebra, BoundaryValueDiffEq, OrdinaryDiffEqTsit5, SciMLBase
33

44
f(u, p, t) = [p[1] * u[1] - p[2] * u[1] * u[2], p[3] * u[1] * u[2] - p[4] * u[2]]
55
function f!(du, u, p, t)
@@ -24,10 +24,22 @@
2424

2525
jac_alg = BVPJacobianAlgorithm(AutoForwardDiff(; chunksize = 2))
2626

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+
2738
# Multi-Point BVP
39+
# nlls is properly inferred as false for StandardBVProblem without bcresid_prototype
2840
@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)
3143

3244
# Shooting methods have deep type instability from NonlinearSolve/OrdinaryDiffEq
3345
# that requires further investigation. The solvers work correctly but return type

0 commit comments

Comments
 (0)