Skip to content

Commit 5417dc6

Browse files
Merge pull request #938 from AayushSabharwal/as/scimlfn-specialization
fix: retain specialization of explicit `f` in `remake`
2 parents 1335076 + 694e0bb commit 5417dc6

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

src/problems/problem_utils.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ function Base.summary(io::IO, prob::AbstractDEProblem)
2626
prob.tspan isa Function ?
2727
"Unknown" : (prob.tspan === nothing ?
2828
"Nothing" : typeof(prob.tspan[1])),
29-
no_color,
30-
". In-place: ", type_color, isinplace(prob), no_color)
29+
no_color,
30+
". In-place: ", type_color, isinplace(prob), no_color)
3131
init = initialization_status(prob)
3232
!isnothing(init) && begin
3333
println(io)
@@ -120,7 +120,6 @@ function Base.show(io::IO, mime::MIME"text/plain", A::AbstractDEProblem)
120120
println(io)
121121
print(io, "u0: ")
122122
show(io, mime, A.u0)
123-
124123
end
125124
function Base.show(io::IO, mime::MIME"text/plain", A::AbstractNoiseProblem)
126125
summary(io, A)

src/remake.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ function remake(
143143
T = parameterless_type(func)
144144
f = isdefined(func, :f) ? func.f : func.f1
145145
elseif f isa AbstractSciMLFunction
146+
iip = isinplace(f)
147+
spec = specialization(f)
146148
# if `f` is a SciMLFunction, create that type
147149
T = parameterless_type(f)
148150
# properties of `f` take priority over those in the existing `func`

test/remake_tests.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,3 +417,11 @@ end
417417
prob2 = remake(prob; u0 = zeros(2))
418418
@test prob2.f.f.jac == fjac!
419419
end
420+
421+
@testset "Issue#925: `remake` retains specialization of explicit `f`" begin
422+
f = ODEFunction{false, SciMLBase.FullSpecialize}((u, p, t) -> u)
423+
prob = ODEProblem(f, nothing, nothing)
424+
@test SciMLBase.specialization(prob.f) == SciMLBase.FullSpecialize
425+
prob2 = remake(ODEProblem((u, p, t) -> 2 .* u, nothing, nothing); f = f)
426+
@test SciMLBase.specialization(prob2.f) == SciMLBase.FullSpecialize
427+
end

0 commit comments

Comments
 (0)