Skip to content

Commit 0f2a62f

Browse files
committed
fix: minor test fixes
1 parent adac560 commit 0f2a62f

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

src/globalization/line_search.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ function __internal_init(
101101
args...; stats, internalnorm::IN = DEFAULT_NORM, kwargs...) where {F, IN}
102102
T = promote_type(eltype(fu), eltype(u))
103103
if u isa Number
104-
autodiff = get_concrete_forward_ad(alg.autodiff, prob; check_forward_mode = true)
104+
autodiff = get_dense_ad(get_concrete_forward_ad(
105+
alg.autodiff, prob; check_forward_mode = true))
105106
if !(autodiff isa AutoForwardDiff ||
106107
autodiff isa AutoPolyesterForwardDiff ||
107108
autodiff isa AutoFiniteDiff)

src/internal/jacobian.jl

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,15 @@ function JacobianCache(prob, alg, f::F, fu_, u, p; stats, autodiff = nothing,
9999
# While this is technically wasteful, it gives out the type of the Jacobian
100100
# which is needed to create the linear solver cache
101101
stats.njacs += 1
102-
if iip
103-
DI.jacobian(f, fu, di_extras, autodiff, u, Constant(p))
102+
if has_analytic_jac
103+
__similar(
104+
fu, promote_type(eltype(fu), eltype(u)), length(fu), length(u))
104105
else
105-
DI.jacobian(f, autodiff, u, Constant(p))
106+
if iip
107+
DI.jacobian(f, fu, di_extras, autodiff, u, Constant(p))
108+
else
109+
DI.jacobian(f, autodiff, u, Constant(p))
110+
end
106111
end
107112
else
108113
zero(init_jacobian(sdifft_extras; preserve_immutable = Val(true)))
@@ -120,9 +125,10 @@ function JacobianCache(prob, alg, f::F, ::Number, u::Number, p; stats,
120125
autodiff = nothing, kwargs...) where {F}
121126
fu = f(u, p)
122127
if SciMLBase.has_jac(f) || SciMLBase.has_vjp(f) || SciMLBase.has_jvp(f)
123-
return JacobianCache{false}(u, f, fu, u, p, stats, autodiff, nothing)
128+
return JacobianCache{false}(u, f, fu, u, p, stats, autodiff, nothing, nothing)
124129
end
125-
autodiff = get_concrete_forward_ad(autodiff, prob; check_forward_mode = false)
130+
autodiff = get_dense_ad(get_concrete_forward_ad(
131+
autodiff, prob; check_forward_mode = false))
126132
di_extras = DI.prepare_derivative(f, get_dense_ad(autodiff), u, Constant(prob.p))
127133
return JacobianCache{false}(u, f, fu, u, p, stats, autodiff, di_extras, nothing)
128134
end

test/misc/bruss_tests.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,6 @@
7373

7474
cache = init(
7575
prob_brusselator_2d, NewtonRaphson(; autodiff = AutoSparse(AutoForwardDiff())))
76-
@test maximum(cache.sdifft_extras.jac_cache.coloring.colorvec) == 12
77-
@test cache.sdifft_extras.autodiff isa AutoSparse{<:AutoForwardDiff}
76+
@test maximum(cache.jac_cache.sdifft_extras.coloring.colorvec) == 12
77+
@test cache.jac_cache.autodiff isa AutoSparse{<:AutoForwardDiff}
7878
end

0 commit comments

Comments
 (0)