Skip to content

Commit

Permalink
Format .jl files [skip ci] (#436)
Browse files Browse the repository at this point in the history
Co-authored-by: jverzani <[email protected]>
  • Loading branch information
github-actions[bot] and jverzani authored Jul 29, 2024
1 parent 44034e3 commit 3fade10
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
12 changes: 7 additions & 5 deletions src/convergence.jl
Original file line number Diff line number Diff line change
Expand Up @@ -200,17 +200,18 @@ function iszero_Δx(
end

# test when fconverged to ensure not runawa
function is_small_Δx(M::AbstractUnivariateZeroMethod,
state::AbstractUnivariateZeroState,
options)
function is_small_Δx(
M::AbstractUnivariateZeroMethod,
state::AbstractUnivariateZeroState,
options,
)
δ = abs(state.xn1 - state.xn0)
δₐ, δᵣ = options.xabstol, options.xreltol
Δₓ = max(_unitless(δₐ), _unitless(abs(state.xn1)) * δᵣ)
Δₓ = sqrt(sqrt(sqrt((abs(_unitless(Δₓ)))))) # faster than x^(1/8)
return δ Δₓ
end


isnan_f(M::AbstractBracketingMethod, state) = isnan(state.fxn1) || isnan(state.fxn0)
isnan_f(M::AbstractNonBracketingMethod, state) = isnan(state.fxn1)

Expand Down Expand Up @@ -313,7 +314,8 @@ function decide_convergence(
# this is the case where runaway can happen
## XXX Need a good heuristic to catch that
is_approx_zero_f(M, state, options, :relaxed) &&
is_small_Δx(M, state, options) && return xn1
is_small_Δx(M, state, options) &&
return xn1
end
end

Expand Down
2 changes: 1 addition & 1 deletion src/find_zeros.jl
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ end

# adjust what we mean by x1 ~ x2 for purposes of adding a new zero
function approx_close(z1, z2, xatol, xrtol)
z₁,z₂,δ,ϵ = _unitless.((z1, z2, xatol, xrtol))
z₁, z₂, δ, ϵ = _unitless.((z1, z2, xatol, xrtol))
return isapprox(z₁, z₂; atol=sqrt(δ), rtol=sqrt(ϵ))
end

Expand Down
2 changes: 1 addition & 1 deletion test/test_composable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ using ForwardDiff
@test xrts[1] 1.886053370668014s

# issue #434
xzs1=find_zeros(x -> cos(x / 1u"m"), -1.6u"m",2u"m")
xzs1 = find_zeros(x -> cos(x / 1u"m"), -1.6u"m", 2u"m")
@test length(xzs1) == 2 && maximum(xzs1) 1.5707963267948966 * u"m"
end

Expand Down

0 comments on commit 3fade10

Please sign in to comment.