Skip to content

Commit 8cd8c7f

Browse files
committed
fix: conditionally remake
1 parent 9ea1147 commit 8cd8c7f

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/solve.jl

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,20 +1152,24 @@ function get_concrete_problem(prob::NonlinearProblem, isadapt; kwargs...)
11521152
p = get_concrete_p(prob, kwargs)
11531153
u0 = get_concrete_u0(prob, isadapt, nothing, kwargs)
11541154
u0 = promote_u0(u0, p, nothing)
1155-
f_promote = promote_f(
1156-
prob.f, Val(SciMLBase.specialization(prob.f)), u0, p
1157-
)
1158-
remake(prob; u0 = u0, p = p, f = f_promote)
1155+
f_promote = promote_f(prob.f, Val(SciMLBase.specialization(prob.f)), u0, p)
1156+
if f_promote === prob.f && u0 === prob.u0 && p === prob.p
1157+
return prob
1158+
else
1159+
return remake(prob; u0 = u0, p = p, f = f_promote)
1160+
end
11591161
end
11601162

11611163
function get_concrete_problem(prob::NonlinearLeastSquaresProblem, isadapt; kwargs...)
11621164
p = get_concrete_p(prob, kwargs)
11631165
u0 = get_concrete_u0(prob, isadapt, nothing, kwargs)
11641166
u0 = promote_u0(u0, p, nothing)
1165-
f_promote = promote_f(
1166-
prob.f, Val(SciMLBase.specialization(prob.f)), u0, p
1167-
)
1168-
remake(prob; u0 = u0, p = p, f = f_promote)
1167+
f_promote = promote_f(prob.f, Val(SciMLBase.specialization(prob.f)), u0, p)
1168+
if f_promote === prob.f && u0 === prob.u0 && p === prob.p
1169+
return prob
1170+
else
1171+
return remake(prob; u0 = u0, p = p, f = f_promote)
1172+
end
11691173
end
11701174

11711175
function get_concrete_problem(prob::AbstractEnsembleProblem, isadapt; kwargs...)

0 commit comments

Comments
 (0)