From 834516a74acea89793562a7bf380d276a696cb48 Mon Sep 17 00:00:00 2001 From: Avik Pal Date: Sat, 5 Oct 2024 14:05:52 -0400 Subject: [PATCH] fix: partial revert of previous fix --- src/internal/helpers.jl | 5 ++--- src/internal/jacobian.jl | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/internal/helpers.jl b/src/internal/helpers.jl index afc24ce5b..5334f11dc 100644 --- a/src/internal/helpers.jl +++ b/src/internal/helpers.jl @@ -1,9 +1,8 @@ # Evaluate the residual function at a given point function evaluate_f(prob::AbstractNonlinearProblem{uType, iip}, u) where {uType, iip} - (; f, u0, p) = prob + (; f, p) = prob if iip - fu = f.resid_prototype === nothing ? zero(u) : - promote_type(eltype(u), eltype(f.resid_prototype)).(f.resid_prototype) + fu = f.resid_prototype === nothing ? zero(u) : similar(f.resid_prototype) f(fu, u, p) else fu = f(u, p) diff --git a/src/internal/jacobian.jl b/src/internal/jacobian.jl index 0f885de47..b78eb7383 100644 --- a/src/internal/jacobian.jl +++ b/src/internal/jacobian.jl @@ -92,11 +92,10 @@ function JacobianCache(prob, alg, f::F, fu_, u, p; stats, autodiff = nothing, end end else - # NOTE: don't use similar because that might lead to an unwrapped array if eltype(f.jac_prototype) <: Bool - promote_type(eltype(fu), eltype(u)).(f.jac_prototype) + similar(f.jac_prototype, promote_type(eltype(fu), eltype(u))) else - copy(f.jac_prototype) + similar(f.jac_prototype) end end end