Skip to content

Commit 6d6339e

Browse files
authored
Only return alpha in _hzI12 (#124)
* Update mayterminate reference instead of returning the value * Test infinite failure
1 parent 0757cd2 commit 6d6339e

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/initialguess.jl

+7-6
Original file line numberDiff line numberDiff line change
@@ -225,15 +225,16 @@ function _hzI12(alpha::T,
225225

226226
iterfinite = 1
227227
while !isfinite(phitest)
228-
alphatest = psi3 * alphatest
228+
if iterfinite >= iterfinitemax
229+
mayterminate[] = true
230+
return T(0)
231+
# TODO: Throw error / LineSearchException instead?
232+
# error("Failed to achieve finite test value; alphatest = ", alphatest)
233+
end
229234

235+
alphatest = psi3 * alphatest
230236
phitest = ϕ(alphatest)
231-
232237
iterfinite += 1
233-
if iterfinite >= iterfinitemax
234-
return T(0), true
235-
# error("Failed to achieve finite test value; alphatest = ", alphatest)
236-
end
237238
end
238239
a = ((phitest-phi_0)/alphatest - dphi_0)/alphatest # quadratic fit
239240

test/initial.jl

+5
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929
is(ls, state, phi_0, dphi_0, df)
3030
@test state.alpha == 0.4999999999999999
3131
@test ls.mayterminate[] == true
32+
dfinf = NLSolversBase.NonDifferentiable(x->Inf, x)
33+
is = InitialHagerZhang(α0 = 1.0)
34+
is(ls, state, phi_0, dphi_0, dfinf)
35+
@test state.alpha == 0
36+
@test ls.mayterminate[] == true
3237

3338
# Test Static unscaled
3439
ls = HagerZhang()

0 commit comments

Comments
 (0)