Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: retain specialization of explicit f in remake #938

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/problems/problem_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ function Base.summary(io::IO, prob::AbstractDEProblem)
prob.tspan isa Function ?
"Unknown" : (prob.tspan === nothing ?
"Nothing" : typeof(prob.tspan[1])),
no_color,
". In-place: ", type_color, isinplace(prob), no_color)
no_color,
". In-place: ", type_color, isinplace(prob), no_color)
init = initialization_status(prob)
!isnothing(init) && begin
println(io)
Expand Down Expand Up @@ -120,7 +120,6 @@ function Base.show(io::IO, mime::MIME"text/plain", A::AbstractDEProblem)
println(io)
print(io, "u0: ")
show(io, mime, A.u0)

end
function Base.show(io::IO, mime::MIME"text/plain", A::AbstractNoiseProblem)
summary(io, A)
Expand Down
2 changes: 2 additions & 0 deletions src/remake.jl
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ function remake(
T = parameterless_type(func)
f = isdefined(func, :f) ? func.f : func.f1
elseif f isa AbstractSciMLFunction
iip = isinplace(f)
spec = specialization(f)
# if `f` is a SciMLFunction, create that type
T = parameterless_type(f)
# properties of `f` take priority over those in the existing `func`
Expand Down
8 changes: 8 additions & 0 deletions test/remake_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -417,3 +417,11 @@ end
prob2 = remake(prob; u0 = zeros(2))
@test prob2.f.f.jac == fjac!
end

@testset "Issue#925: `remake` retains specialization of explicit `f`" begin
f = ODEFunction{false, SciMLBase.FullSpecialize}((u, p, t) -> u)
prob = ODEProblem(f, nothing, nothing)
@test SciMLBase.specialization(prob.f) == SciMLBase.FullSpecialize
prob2 = remake(ODEProblem((u, p, t) -> 2 .* u, nothing, nothing); f = f)
@test SciMLBase.specialization(prob2.f) == SciMLBase.FullSpecialize
end
Loading