Skip to content

Commit

Permalink
Run formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed May 25, 2024
1 parent 28352f3 commit e67f4f2
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 30 deletions.
9 changes: 4 additions & 5 deletions src/core/approximate_jacobian.jl
Original file line number Diff line number Diff line change
Expand Up @@ -165,18 +165,17 @@ function SciMLBase.__init(
INV = store_inverse_jacobian(alg.update_rule)

linsolve = get_linear_solver(alg.descent)
initialization_cache = __internal_init(
prob, alg.initialization, alg, f, fu, u, p; stats, linsolve, maxiters, internalnorm)
initialization_cache = __internal_init(prob, alg.initialization, alg, f, fu, u, p;
stats, linsolve, maxiters, internalnorm)

abstol, reltol, termination_cache = init_termination_cache(
prob, abstol, reltol, fu, u, termination_condition)
linsolve_kwargs = merge((; abstol, reltol), linsolve_kwargs)

J = initialization_cache(nothing)
inv_workspace, J = INV ? __safe_inv_workspace(J) : (nothing, J)
descent_cache = __internal_init(
prob, alg.descent, J, fu, u; stats, abstol, reltol, internalnorm,
linsolve_kwargs, pre_inverted = Val(INV), timer)
descent_cache = __internal_init(prob, alg.descent, J, fu, u; stats, abstol, reltol,
internalnorm, linsolve_kwargs, pre_inverted = Val(INV), timer)
du = get_du(descent_cache)

reinit_rule_cache = __internal_init(alg.reinit_rule, J, fu, u, du)
Expand Down
11 changes: 6 additions & 5 deletions src/core/generalized_first_order.jl
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,10 @@ end

function SciMLBase.__init(
prob::AbstractNonlinearProblem{uType, iip}, alg::GeneralizedFirstOrderAlgorithm,
args...; stats=empty_nlstats(), alias_u0 = false, maxiters = 1000, abstol = nothing,
reltol = nothing, maxtime = nothing, termination_condition = nothing,
internalnorm = DEFAULT_NORM, linsolve_kwargs = (;), kwargs...) where {uType, iip}
args...; stats = empty_nlstats(), alias_u0 = false, maxiters = 1000,
abstol = nothing, reltol = nothing, maxtime = nothing,
termination_condition = nothing, internalnorm = DEFAULT_NORM,
linsolve_kwargs = (;), kwargs...) where {uType, iip}
timer = get_timer_output()
@static_timeit timer "cache construction" begin
(; f, u0, p) = prob
Expand All @@ -173,8 +174,8 @@ function SciMLBase.__init(
prob, alg, f, fu, u, p; stats, autodiff = alg.jacobian_ad, linsolve,
jvp_autodiff = alg.forward_ad, vjp_autodiff = alg.reverse_ad)
J = jac_cache(nothing)
descent_cache = __internal_init(prob, alg.descent, J, fu, u; stats, abstol, reltol,
internalnorm, linsolve_kwargs, timer)
descent_cache = __internal_init(prob, alg.descent, J, fu, u; stats, abstol,
reltol, internalnorm, linsolve_kwargs, timer)
du = get_du(descent_cache)

if alg.trustregion !== missing && alg.linesearch !== missing
Expand Down
2 changes: 1 addition & 1 deletion src/core/generic.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function SciMLBase.__solve(prob::Union{NonlinearProblem, NonlinearLeastSquaresProblem},
alg::AbstractNonlinearSolveAlgorithm, args...; stats=empty_nlstats(), kwargs...)
alg::AbstractNonlinearSolveAlgorithm, args...; stats = empty_nlstats(), kwargs...)
cache = SciMLBase.__init(prob, alg, args...; stats, kwargs...)
return solve!(cache)
end
Expand Down
8 changes: 4 additions & 4 deletions src/descent/steepest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ end
@internal_caches SteepestDescentCache :lincache

@inline function __internal_init(
prob::AbstractNonlinearProblem, alg::SteepestDescent, J, fu,
u; stats, shared::Val{N} = Val(1), pre_inverted::Val{INV} = False,
prob::AbstractNonlinearProblem, alg::SteepestDescent, J, fu, u;
stats, shared::Val{N} = Val(1), pre_inverted::Val{INV} = False,
linsolve_kwargs = (;), abstol = nothing, reltol = nothing,
timer = get_timer_output(), kwargs...) where {INV, N}
INV && @assert length(fu)==length(u) "Non-Square Jacobian Inverse doesn't make sense."
Expand All @@ -40,8 +40,8 @@ end
@bb δu_ = similar(u)
end
if INV
lincache = LinearSolverCache(alg, alg.linsolve, transpose(J), _vec(fu),
_vec(u); stats, abstol, reltol, linsolve_kwargs...)
lincache = LinearSolverCache(alg, alg.linsolve, transpose(J), _vec(fu), _vec(u);

Check warning on line 43 in src/descent/steepest.jl

View check run for this annotation

Codecov / codecov/patch

src/descent/steepest.jl#L43

Added line #L43 was not covered by tests
stats, abstol, reltol, linsolve_kwargs...)
else
lincache = nothing
end
Expand Down
8 changes: 4 additions & 4 deletions src/globalization/line_search.jl
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,8 @@ end
end

function __internal_init(
prob::AbstractNonlinearProblem, alg::RobustNonMonotoneLineSearch, f::F, fu,
u, p, args...; stats, internalnorm::IN = DEFAULT_NORM, kwargs...) where {F, IN}
prob::AbstractNonlinearProblem, alg::RobustNonMonotoneLineSearch, f::F, fu, u,
p, args...; stats, internalnorm::IN = DEFAULT_NORM, kwargs...) where {F, IN}
@bb u_cache = similar(u)
@bb fu_cache = similar(fu)
T = promote_type(eltype(fu), eltype(u))
Expand Down Expand Up @@ -343,8 +343,8 @@ end
end

function __internal_init(
prob::AbstractNonlinearProblem, alg::LiFukushimaLineSearch, f::F, fu, u,
p, args...; stats, internalnorm::IN = DEFAULT_NORM, kwargs...) where {F, IN}
prob::AbstractNonlinearProblem, alg::LiFukushimaLineSearch, f::F, fu, u, p,
args...; stats, internalnorm::IN = DEFAULT_NORM, kwargs...) where {F, IN}
@bb u_cache = similar(u)
@bb fu_cache = similar(fu)
T = promote_type(eltype(fu), eltype(u))
Expand Down
4 changes: 2 additions & 2 deletions src/globalization/trust_region.jl
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,8 @@ end
@inline __expand_factor(::Nothing, ::Type{T}, method) where {T} = T(2)

function __internal_init(
prob::AbstractNonlinearProblem, alg::GenericTrustRegionScheme, f::F, fu,
u, p, args...; stats, internalnorm::IF = DEFAULT_NORM, kwargs...) where {F, IF}
prob::AbstractNonlinearProblem, alg::GenericTrustRegionScheme, f::F, fu, u,
p, args...; stats, internalnorm::IF = DEFAULT_NORM, kwargs...) where {F, IF}
T = promote_type(eltype(u), eltype(fu))
u0_norm = internalnorm(u)
fu_norm = internalnorm(fu)
Expand Down
4 changes: 2 additions & 2 deletions src/internal/approximate_initialization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ end

function __internal_init(
prob::AbstractNonlinearProblem, alg::TrueJacobianInitialization, solver, f::F, fu,
u, p; linsolve = missing, internalnorm::IN = DEFAULT_NORM, kwargs...) where {F, IN}
u, p; stats, linsolve = missing, internalnorm::IN = DEFAULT_NORM, kwargs...) where {F, IN}
autodiff = get_concrete_forward_ad(
alg.autodiff, prob; check_forward_mode = false, kwargs...)
jac_cache = JacobianCache(prob, solver, prob.f, fu, u, p; autodiff, linsolve)
jac_cache = JacobianCache(prob, solver, prob.f, fu, u, p; stats, autodiff, linsolve)

Check warning on line 153 in src/internal/approximate_initialization.jl

View check run for this annotation

Codecov / codecov/patch

src/internal/approximate_initialization.jl#L153

Added line #L153 was not covered by tests
J = alg.structure(jac_cache(nothing))
return InitializedApproximateJacobianCache(
J, alg.structure, alg, jac_cache, false, internalnorm)
Expand Down
9 changes: 4 additions & 5 deletions src/internal/jacobian.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,8 @@ function reinit_cache!(cache::JacobianCache{iip}, args...; p = cache.p,
cache.uf = JacobianWrapper{iip}(cache.f, p)
end

function JacobianCache(
prob, alg, f::F, fu_, u, p; stats, autodiff = nothing, vjp_autodiff = nothing,
jvp_autodiff = nothing, linsolve = missing) where {F}
function JacobianCache(prob, alg, f::F, fu_, u, p; stats, autodiff = nothing,
vjp_autodiff = nothing, jvp_autodiff = nothing, linsolve = missing) where {F}
iip = isinplace(prob)
uf = JacobianWrapper{iip}(f, p)

Expand Down Expand Up @@ -96,8 +95,8 @@ function JacobianCache(
J, f, uf, fu, u, p, jac_cache, alg, stats, autodiff, vjp_autodiff, jvp_autodiff)
end

function JacobianCache(
prob, alg, f::F, ::Number, u::Number, p; stats, autodiff = nothing, kwargs...) where {F}
function JacobianCache(prob, alg, f::F, ::Number, u::Number, p; stats,
autodiff = nothing, kwargs...) where {F}
uf = JacobianWrapper{false}(f, p)
autodiff = get_concrete_forward_ad(autodiff, prob; check_forward_mode = false)
if !(autodiff isa AutoForwardDiff ||
Expand Down
5 changes: 3 additions & 2 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,9 @@ function __build_solution_less_specialize(prob::AbstractNonlinearProblem, alg, u
T = eltype(eltype(u))
N = ndims(u)

return SciMLBase.NonlinearSolution{T, N, typeof(u), typeof(resid), typeof(prob),
typeof(alg), Any, typeof(left), typeof(stats), typeof(trace)}(
return SciMLBase.NonlinearSolution{
T, N, typeof(u), typeof(resid), typeof(prob), typeof(alg),
Any, typeof(left), typeof(stats), typeof(trace)}(
u, resid, prob, alg, retcode, original, left, right, stats, trace)
end

Expand Down

0 comments on commit e67f4f2

Please sign in to comment.