Skip to content

Commit

Permalink
fix: minor test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed Sep 27, 2024
1 parent be0f8da commit ef2ab48
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/globalization/line_search.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ function __internal_init(
args...; stats, internalnorm::IN = DEFAULT_NORM, kwargs...) where {F, IN}
T = promote_type(eltype(fu), eltype(u))
if u isa Number
autodiff = get_concrete_forward_ad(alg.autodiff, prob; check_forward_mode = true)
autodiff = get_dense_ad(get_concrete_forward_ad(
alg.autodiff, prob; check_forward_mode = true))
if !(autodiff isa AutoForwardDiff ||
autodiff isa AutoPolyesterForwardDiff ||
autodiff isa AutoFiniteDiff)
Expand Down
11 changes: 8 additions & 3 deletions src/internal/jacobian.jl
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,15 @@ function JacobianCache(prob, alg, f::F, fu_, u, p; stats, autodiff = nothing,
# While this is technically wasteful, it gives out the type of the Jacobian
# which is needed to create the linear solver cache
stats.njacs += 1
if iip
DI.jacobian(f, fu, di_extras, autodiff, u, Constant(p))
if has_analytic_jac
__similar(
fu, promote_type(eltype(fu), eltype(u)), length(fu), length(u))
else
DI.jacobian(f, autodiff, u, Constant(p))
if iip
DI.jacobian(f, fu, di_extras, autodiff, u, Constant(p))
else
DI.jacobian(f, autodiff, u, Constant(p))
end
end
else
zero(init_jacobian(sdifft_extras; preserve_immutable = Val(true)))
Expand Down
4 changes: 2 additions & 2 deletions test/misc/bruss_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,6 @@

cache = init(
prob_brusselator_2d, NewtonRaphson(; autodiff = AutoSparse(AutoForwardDiff())))
@test maximum(cache.sdifft_extras.jac_cache.coloring.colorvec) == 12
@test cache.sdifft_extras.autodiff isa AutoSparse{<:AutoForwardDiff}
@test maximum(cache.jac_cache.sdifft_extras.coloring.colorvec) == 12
@test cache.jac_cache.autodiff isa AutoSparse{<:AutoForwardDiff}
end

0 comments on commit ef2ab48

Please sign in to comment.