Skip to content

Commit 3b9665d

Browse files
committed
Fix
1 parent 7bd69fb commit 3b9665d

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

  • DifferentiationInterface

DifferentiationInterface/ext/DifferentiationInterfaceFiniteDiffExt/onearg.jl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,11 +462,19 @@ function DI.prepare_hessian_nokwarg(
462462
end
463463
relstep_h = if isnothing(backend.relstep)
464464
default_relstep(fdhtype(backend), eltype(x))
465+
else
466+
backend.relstep
467+
end
468+
absstep_g = if isnothing(backend.absstep)
469+
relstep_g
470+
else
471+
backend.absstep
472+
end
473+
absstep_h = if isnothing(backend.absstep)
474+
relstep_h
465475
else
466476
backend.absstep
467477
end
468-
absstep_g = isnothing(backend.absstep) ? relstep_g : backend.absstep
469-
absstep_h = isnothing(backend.absstep) ? relstep_h : backend.absstep
470478
return FiniteDiffHessianPrep(
471479
_sig, gradient_cache, hessian_cache, relstep_g, absstep_g, relstep_h, absstep_h
472480
)

DifferentiationInterface/test/Back/FiniteDiff/test.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ end;
8888
@test prep.relstep == 0.1
8989
@test prep.absstep == 1000
9090
end
91+
prep = prepare_hessian(sum, backend, [1.0])
92+
@test prep.absstep_g == 1000
93+
@test prep.absstep_h == 1000
94+
@test prep.relstep_g == 0.1
95+
@test prep.relstep_h == 0.1
9196

9297
backend = AutoFiniteDiff(; relstep=0.1)
9398
preps = [
@@ -103,4 +108,9 @@ end;
103108
@test prep.relstep == 0.1
104109
@test prep.absstep == 0.1
105110
end
111+
prep = prepare_hessian(sum, backend, [1.0])
112+
@test prep.absstep_g == 0.1
113+
@test prep.absstep_h == 0.1
114+
@test prep.relstep_g == 0.1
115+
@test prep.relstep_h == 0.1
106116
end

0 commit comments

Comments
 (0)