Skip to content

Commit

Permalink
Remove special iszero handling
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed Oct 9, 2023
1 parent af3e026 commit b25eb74
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 9 deletions.
4 changes: 1 addition & 3 deletions src/gaussnewton.jl
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,7 @@ function perform_step!(cache::GaussNewtonCache{false})
cache.u = @. u - cache.du # `u` might not support mutation
cache.fu_new = f(cache.u, p)

Check warning on line 133 in src/gaussnewton.jl

View check run for this annotation

Codecov / codecov/patch

src/gaussnewton.jl#L132-L133

Added lines #L132 - L133 were not covered by tests

(cache.internalnorm(cache.fu_new .- cache.fu1) < cache.abstol ||
cache.internalnorm(cache.fu_new) < cache.abstol) &&
(cache.force_stop = true)
(cache.internalnorm(cache.fu_new) < cache.abstol) && (cache.force_stop = true)
cache.fu1 = cache.fu_new
cache.stats.nf += 1
cache.stats.njacs += 1
Expand Down
4 changes: 2 additions & 2 deletions src/levenberg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ end

function perform_step!(cache::LevenbergMarquardtCache{true})
@unpack fu1, f, make_new_J = cache
if _iszero(fu1)
if iszero(fu1)
cache.force_stop = true
return nothing
end
Expand Down Expand Up @@ -256,7 +256,7 @@ end

function perform_step!(cache::LevenbergMarquardtCache{false})
@unpack fu1, f, make_new_J = cache
if _iszero(fu1)
if iszero(fu1)

Check warning on line 259 in src/levenberg.jl

View check run for this annotation

Codecov / codecov/patch

src/levenberg.jl#L259

Added line #L259 was not covered by tests
cache.force_stop = true
return nothing
end
Expand Down
4 changes: 0 additions & 4 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,6 @@ end
concrete_jac(_) = nothing
concrete_jac(::AbstractNewtonAlgorithm{CJ}) where {CJ} = CJ

# Circumventing https://github.com/SciML/RecursiveArrayTools.jl/issues/277
_iszero(x) = iszero(x)
_iszero(x::ArrayPartition) = all(_iszero, x.x)

_mutable_zero(x) = zero(x)
_mutable_zero(x::SArray) = MArray(x)

Expand Down

0 comments on commit b25eb74

Please sign in to comment.