Skip to content

Commit

Permalink
Merge pull request #127 from SciML/ap/propagate_kwargs
Browse files Browse the repository at this point in the history
Dispatch didn't propagate problem kwargs
  • Loading branch information
ChrisRackauckas authored Feb 15, 2024
2 parents 3dfa6a2 + 05c80bb commit f809d0a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions lib/SimpleNonlinearSolve/.github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
group:
- Core
Expand Down
2 changes: 1 addition & 1 deletion lib/SimpleNonlinearSolve/Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "SimpleNonlinearSolve"
uuid = "727e6d20-b764-4bd8-a329-72de5adea6c7"
authors = ["SciML"]
version = "1.4.1"
version = "1.4.2"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand Down
4 changes: 2 additions & 2 deletions lib/SimpleNonlinearSolve/src/SimpleNonlinearSolve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ include("ad.jl")
# Set the default bracketing method to ITP
SciMLBase.solve(prob::IntervalNonlinearProblem; kwargs...) = solve(prob, ITP(); kwargs...)
function SciMLBase.solve(prob::IntervalNonlinearProblem, alg::Nothing, args...; kwargs...)
return solve(prob, ITP(), args...; kwargs...)
return solve(prob, ITP(), args...; prob.kwargs..., kwargs...)
end

# By Pass the highlevel checks for NonlinearProblem for Simple Algorithms
Expand All @@ -67,7 +67,7 @@ function SciMLBase.solve(
new_p = p !== nothing ? p : prob.p
return __internal_solve_up(
prob, sensealg, new_u0, u0 === nothing, new_p, p === nothing,
alg, args...; kwargs...)
alg, args...; prob.kwargs..., kwargs...)
end

function __internal_solve_up(_prob::NonlinearProblem, sensealg, u0, u0_changed, p,
Expand Down
9 changes: 7 additions & 2 deletions lib/SimpleNonlinearSolve/test/core/rootfind_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,19 @@ end
p = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]

@testset "$(nameof(typeof(alg)))" for alg in (SimpleDFSane(), SimpleTrustRegion(),
SimpleHalley(),
SimpleTrustRegion(; nlsolve_update_rule = Val(true)))
SimpleHalley(), SimpleTrustRegion(; nlsolve_update_rule = Val(true)))
sol = benchmark_nlsolve_oop(newton_fails, u0, p; solver = alg)
@test SciMLBase.successful_retcode(sol)
@test all(abs.(newton_fails(sol.u, p)) .< 1e-9)
end
end

@testitem "Kwargs Propagation" setup=[RootfindingTesting] begin
prob = NonlinearProblem(quadratic_f, ones(4), 2.0; maxiters = 2)
sol = solve(prob, SimpleNewtonRaphson())
@test sol.retcode === ReturnCode.MaxIters
end

@testitem "Allocation Checks" setup=[RootfindingTesting] begin
@testset "$(nameof(typeof(alg)))" for alg in (SimpleNewtonRaphson(),
SimpleHalley(), SimpleBroyden(), SimpleKlement(), SimpleLimitedMemoryBroyden(),
Expand Down

0 comments on commit f809d0a

Please sign in to comment.