From a252d3161acbf8310ebed541cc3b4914083031ba Mon Sep 17 00:00:00 2001 From: Herman Sletmoen Date: Sun, 13 Apr 2025 18:55:14 +0200 Subject: [PATCH 1/3] Fix type instability --- src/remake.jl | 2 +- test/downstream/solution_interface.jl | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/remake.jl b/src/remake.jl index 25a02ec98..d14b9d195 100644 --- a/src/remake.jl +++ b/src/remake.jl @@ -229,7 +229,7 @@ function remake(prob::ODEProblem; f = missing, iip = isinplace(prob) - if build_initializeprob == Val{true} || build_initializeprob == true + if build_initializeprob isa Val{true} || build_initializeprob == true if f !== missing && has_initialization_data(f) initialization_data = remake_initialization_data( prob.f.sys, f, u0, tspan[1], p, newu0, newp) diff --git a/test/downstream/solution_interface.jl b/test/downstream/solution_interface.jl index b59424dd2..1a1d8234c 100644 --- a/test/downstream/solution_interface.jl +++ b/test/downstream/solution_interface.jl @@ -349,3 +349,10 @@ end sol = solve(prob) @test sol(0.6, idxs = y) ≈ 2.0 end + +@testset "Type stability of MTK workflow" begin + @variables x(t) + @mtkbuild sys = ODESystem([D(x) ~ 0.0], t; defaults = [x => 0.0]) + prob = ODEProblem(sys, [], (0.0, 1.0)) + @test_nowarn @inferred solve(prob, Tsit5()) +end From 2d49e1f4c896bab26f49d6b1060e1b7ee67e1e2a Mon Sep 17 00:00:00 2001 From: Herman Sletmoen Date: Sun, 13 Apr 2025 19:10:13 +0200 Subject: [PATCH 2/3] Test issue #985 --- test/downstream/solution_interface.jl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/downstream/solution_interface.jl b/test/downstream/solution_interface.jl index 1a1d8234c..f7b3d6c22 100644 --- a/test/downstream/solution_interface.jl +++ b/test/downstream/solution_interface.jl @@ -355,4 +355,11 @@ end @mtkbuild sys = ODESystem([D(x) ~ 0.0], t; defaults = [x => 0.0]) prob = ODEProblem(sys, [], (0.0, 1.0)) @test_nowarn @inferred solve(prob, Tsit5()) + + @parameters α=1 β=1 γ=1 δ=1 + @variables x(t)=1 y(t)=1 + eqs = [D(x) ~ α * x - β * x * y, D(y) ~ -δ * y + γ * x * y] + @named sys = ODESystem(eqs, t) + prob = ODEProblem(complete(sys), [], (0.0, 1)) + @test_nowarn @inferred remake(prob, u0 = prob.u0, p = prob.p) # was Any end From ff1661982ff762074180a68c9da60fdb6bba8a8d Mon Sep 17 00:00:00 2001 From: Herman Sletmoen Date: Sun, 13 Apr 2025 19:14:25 +0200 Subject: [PATCH 3/3] Format --- test/downstream/initialization.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/test/downstream/initialization.jl b/test/downstream/initialization.jl index c5bbb2a44..6776ccb61 100644 --- a/test/downstream/initialization.jl +++ b/test/downstream/initialization.jl @@ -78,7 +78,6 @@ end @test occursin("Initialization status: OVERDETERMINED", sprint(summary, prob)) end - @testset "CheckInit" begin @testset "ODEProblem" begin function rhs(u, p, t)