Skip to content

Commit

Permalink
Propagate the verbose kwarg
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed Apr 25, 2024
1 parent bcb98c5 commit dc539b9
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/NonlinearSolve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ include("default.jl")

@compile_workload begin
for prob in probs_nls, alg in nls_algs
solve(prob, alg; abstol = 1e-2)
solve(prob, alg; abstol = 1e-2, verbose = false)
end
for prob in probs_nlls, alg in nlls_algs
solve(prob, alg; abstol = 1e-2)
solve(prob, alg; abstol = 1e-2, verbose = false)
end
end
end
Expand Down
7 changes: 4 additions & 3 deletions src/core/approximate_jacobian.jl
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ end
retcode::ReturnCode.T
force_stop::Bool
force_reinit::Bool
kwargs
end

store_inverse_jacobian(::ApproximateJacobianSolveCache{INV}) where {INV} = INV
Expand Down Expand Up @@ -214,7 +215,7 @@ function SciMLBase.__init(
descent_cache, linesearch_cache, trustregion_cache,
update_rule_cache, reinit_rule_cache, inv_workspace, 0, 0, 0,
alg.max_resets, maxiters, maxtime, alg.max_shrink_times, 0, timer,
0.0, termination_cache, trace, ReturnCode.Default, false, false)
0.0, termination_cache, trace, ReturnCode.Default, false, false, kwargs)
end
end

Expand Down Expand Up @@ -284,10 +285,10 @@ function __step!(cache::ApproximateJacobianSolveCache{INV, GB, iip};
hasfield(typeof(cache.trustregion_cache), :trust_region)
descent_result = __internal_solve!(

Check warning on line 286 in src/core/approximate_jacobian.jl

View check run for this annotation

Codecov / codecov/patch

src/core/approximate_jacobian.jl#L286

Added line #L286 was not covered by tests
cache.descent_cache, J, cache.fu, cache.u; new_jacobian,
trust_region = cache.trustregion_cache.trust_region)
trust_region = cache.trustregion_cache.trust_region, cache.kwargs...)
else
descent_result = __internal_solve!(
cache.descent_cache, J, cache.fu, cache.u; new_jacobian)
cache.descent_cache, J, cache.fu, cache.u; new_jacobian, cache.kwargs...)
end
end
δu, descent_intermediates = descent_result.δu, descent_result.extras
Expand Down
7 changes: 4 additions & 3 deletions src/core/generalized_first_order.jl
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ concrete_jac(::GeneralizedFirstOrderAlgorithm{CJ}) where {CJ} = CJ
trace
retcode::ReturnCode.T
force_stop::Bool
kwargs
end

SymbolicIndexingInterface.state_values(cache::GeneralizedFirstOrderAlgorithmCache) = cache.u
Expand Down Expand Up @@ -202,7 +203,7 @@ function SciMLBase.__init(
return GeneralizedFirstOrderAlgorithmCache{iip, GB, maxtime !== nothing}(
fu, u, u_cache, p, du, J, alg, prob, jac_cache, descent_cache, linesearch_cache,
trustregion_cache, 0, 0, maxiters, maxtime, alg.max_shrink_times,
timer, 0.0, true, termination_cache, trace, ReturnCode.Default, false)
timer, 0.0, true, termination_cache, trace, ReturnCode.Default, false, kwargs)
end
end

Expand All @@ -223,10 +224,10 @@ function __step!(cache::GeneralizedFirstOrderAlgorithmCache{iip, GB};
hasfield(typeof(cache.trustregion_cache), :trust_region)
descent_result = __internal_solve!(
cache.descent_cache, J, cache.fu, cache.u; new_jacobian,
trust_region = cache.trustregion_cache.trust_region)
trust_region = cache.trustregion_cache.trust_region, cache.kwargs...)
else
descent_result = __internal_solve!(
cache.descent_cache, J, cache.fu, cache.u; new_jacobian)
cache.descent_cache, J, cache.fu, cache.u; new_jacobian, cache.kwargs...)
end
end
δu, descent_intermediates = descent_result.δu, descent_result.extras
Expand Down
3 changes: 2 additions & 1 deletion src/core/spectral_methods.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ concrete_jac(::GeneralizedDFSane) = nothing
trace
retcode::ReturnCode.T
force_stop::Bool
kwargs
end

function __reinit_internal!(
Expand Down Expand Up @@ -150,7 +151,7 @@ function SciMLBase.__init(prob::AbstractNonlinearProblem, alg::GeneralizedDFSane
return GeneralizedDFSaneCache{isinplace(prob), maxtime !== nothing}(
fu, fu_cache, u, u_cache, prob.p, du, alg, prob, σ_n, T(alg.σ_min),
T(alg.σ_max), linesearch_cache, 0, 0, maxiters, maxtime,
timer, 0.0, tc_cache, trace, ReturnCode.Default, false)
timer, 0.0, tc_cache, trace, ReturnCode.Default, false, kwargs)
end
end

Expand Down
9 changes: 6 additions & 3 deletions src/internal/linear_solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ end
# Use LinearSolve.jl
function (cache::LinearSolverCache)(;
A = nothing, b = nothing, linu = nothing, du = nothing, p = nothing,
weight = nothing, cachedata = nothing, reuse_A_if_factorization = false, kwargs...)
weight = nothing, cachedata = nothing, reuse_A_if_factorization = false,
verbose = true, kwargs...)
cache.nsolve += 1

__update_A!(cache, A, reuse_A_if_factorization)
Expand Down Expand Up @@ -164,8 +165,10 @@ function (cache::LinearSolverCache)(;
# TODO: We need to guard this somehow because this will surely fail if A is on GPU
# TODO: or some fancy Matrix type
if !(cache.linsolve isa QRFactorization{ColumnNorm})
@warn "Potential Rank Deficient Matrix Detected. Attempting to solve using \
Pivoted QR Factorization."
if verbose
@warn "Potential Rank Deficient Matrix Detected. Attempting to solve using \

Check warning on line 169 in src/internal/linear_solve.jl

View check run for this annotation

Codecov / codecov/patch

src/internal/linear_solve.jl#L167-L169

Added lines #L167 - L169 were not covered by tests
Pivoted QR Factorization."
end
@assert (A !== nothing)&&(b !== nothing) "This case is not yet supported. \

Check warning on line 172 in src/internal/linear_solve.jl

View check run for this annotation

Codecov / codecov/patch

src/internal/linear_solve.jl#L172

Added line #L172 was not covered by tests
Please open an issue at \
https://github.com/SciML/NonlinearSolve.jl"
Expand Down

0 comments on commit dc539b9

Please sign in to comment.