Skip to content

Commit 8bacad1

Browse files
committed
Fix Aqua error
1 parent de6eb96 commit 8bacad1

File tree

9 files changed

+40
-37
lines changed

9 files changed

+40
-37
lines changed

lib/NonlinearSolveBase/ext/NonlinearSolveBaseForwardDiffExt.jl

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@ module NonlinearSolveBaseForwardDiffExt
22

33
using ADTypes: ADTypes, AutoForwardDiff, AutoPolyesterForwardDiff
44
using ArrayInterface: ArrayInterface
5-
using CommonSolve: CommonSolve, solve
5+
using CommonSolve: CommonSolve, solve, solve!, init
66
using ConcreteStructs: @concrete
77
using DifferentiationInterface: DifferentiationInterface
88
using FastClosures: @closure
99
using ForwardDiff: ForwardDiff, Dual
1010
using SciMLBase: SciMLBase, AbstractNonlinearProblem, IntervalNonlinearProblem,
1111
NonlinearProblem, NonlinearLeastSquaresProblem, remake
1212

13-
using NonlinearSolveBase: NonlinearSolveBase, ImmutableNonlinearProblem,
14-
AbstractNonlinearSolveAlgorithm, Utils, InternalAPI,
15-
AbstractNonlinearSolveCache, NonlinearSolvePolyAlgorithm
13+
using NonlinearSolveBase: NonlinearSolveBase, ImmutableNonlinearProblem, Utils, InternalAPI,
14+
AbstractNonlinearSolveCache, NonlinearSolvePolyAlgorithm,
15+
NonlinearSolveForwardDiffCache
1616

1717
const DI = DifferentiationInterface
1818

1919
const GENERAL_SOLVER_TYPES = [
20-
Nothing, AbstractNonlinearSolveAlgorithm, NonlinearSolvePolyAlgorithm
20+
Nothing, NonlinearSolvePolyAlgorithm
2121
]
2222

2323
const DualNonlinearProblem = NonlinearProblem{
@@ -135,24 +135,16 @@ for algType in GENERAL_SOLVER_TYPES
135135
end
136136
end
137137

138-
@concrete mutable struct NonlinearSolveForwardDiffCache <: AbstractNonlinearSolveCache
139-
cache
140-
prob
141-
alg
142-
p
143-
values_p
144-
partials_p
145-
end
146-
147138
function InternalAPI.reinit!(
148139
cache::NonlinearSolveForwardDiffCache, args...;
149140
p = cache.p, u0 = NonlinearSolveBase.get_u(cache.cache), kwargs...
150141
)
151142
InternalAPI.reinit!(
152-
cache.cache; p = nodual_value(p), u0 = nodual_value(u0), kwargs...
143+
cache.cache; p = NonlinearSolveBase.nodual_value(p),
144+
u0 = NonlinearSolveBase.nodual_value(u0), kwargs...
153145
)
154146
cache.p = p
155-
cache.values_p = nodual_value(p)
147+
cache.values_p = NonlinearSolveBase.nodual_value(p)
156148
cache.partials_p = ForwardDiff.partials(p)
157149
return cache
158150
end
@@ -161,8 +153,8 @@ for algType in GENERAL_SOLVER_TYPES
161153
@eval function SciMLBase.__init(
162154
prob::DualAbstractNonlinearProblem, alg::$(algType), args...; kwargs...
163155
)
164-
p = nodual_value(prob.p)
165-
newprob = SciMLBase.remake(prob; u0 = nodual_value(prob.u0), p)
156+
p = NonlinearSolveBase.nodual_value(prob.p)
157+
newprob = SciMLBase.remake(prob; u0 = NonlinearSolveBase.nodual_value(prob.u0), p)
166158
cache = init(newprob, alg, args...; kwargs...)
167159
return NonlinearSolveForwardDiffCache(
168160
cache, newprob, alg, prob.p, p, ForwardDiff.partials(prob.p)
@@ -196,8 +188,17 @@ function CommonSolve.solve!(cache::NonlinearSolveForwardDiffCache)
196188
)
197189
end
198190

199-
nodual_value(x) = x
200-
nodual_value(x::Dual) = ForwardDiff.value(x)
201-
nodual_value(x::AbstractArray{<:Dual}) = map(ForwardDiff.value, x)
191+
NonlinearSolveBase.nodual_value(x) = x
192+
NonlinearSolveBase.nodual_value(x::Dual) = ForwardDiff.value(x)
193+
NonlinearSolveBase.nodual_value(x::AbstractArray{<:Dual}) = map(ForwardDiff.value, x)
194+
195+
"""
196+
pickchunksize(x) = pickchunksize(length(x))
197+
pickchunksize(x::Int)
198+
199+
Determine the chunk size for ForwardDiff and PolyesterForwardDiff based on the input length.
200+
"""
201+
@inline NonlinearSolveBase.pickchunksize(x) = pickchunksize(length(x))
202+
@inline NonlinearSolveBase.pickchunksize(x::Int) = ForwardDiff.pickchunksize(x)
202203

203204
end

lib/NonlinearSolveBase/src/NonlinearSolveBase.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ include("descent/geodesic_acceleration.jl")
5858

5959
include("solve.jl")
6060

61+
include("forward_diff.jl")
62+
6163
# Unexported Public API
6264
@compat(public, (L2_NORM, Linf_NORM, NAN_CHECK, UNITLESS_ABS2, get_tolerance))
6365
@compat(public, (nonlinearsolve_forwarddiff_solve, nonlinearsolve_dual_solution))

lib/NonlinearSolveBase/src/common_defaults.jl

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,3 @@ function get_tolerance(::Union{StaticArray, Number}, ::Nothing, ::Type{T}) where
4545
# Rational numbers can throw an error if used inside GPU Kernels
4646
return T(real(oneunit(T)) * (eps(real(one(T)))^(real(T)(0.8))))
4747
end
48-
49-
"""
50-
pickchunksize(x) = pickchunksize(length(x))
51-
pickchunksize(x::Int)
52-
53-
Determine the chunk size for ForwardDiff and PolyesterForwardDiff based on the input length.
54-
"""
55-
@inline pickchunksize(x) = pickchunksize(length(x))
56-
@inline pickchunksize(x::Int) = ForwardDiff.pickchunksize(x)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@concrete mutable struct NonlinearSolveForwardDiffCache <: AbstractNonlinearSolveCache
2+
cache
3+
prob
4+
alg
5+
p
6+
values_p
7+
partials_p
8+
end

lib/NonlinearSolveBase/src/public.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ function nonlinearsolve_dual_solution end
1111
function nonlinearsolve_∂f_∂p end
1212
function nonlinearsolve_∂f_∂u end
1313
function nlls_generate_vjp_function end
14+
function nodual_value end
15+
function pickchunksize end
1416

1517
# Nonlinear Solve Termination Conditions
1618
abstract type AbstractNonlinearTerminationMode end

lib/NonlinearSolveFirstOrder/src/NonlinearSolveFirstOrder.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ using NonlinearSolveBase: NonlinearSolveBase, AbstractNonlinearSolveAlgorithm,
2222
Utils, InternalAPI, get_timer_output, @static_timeit,
2323
update_trace!, L2_NORM, NonlinearSolvePolyAlgorithm,
2424
NewtonDescent, DampedNewtonDescent, GeodesicAcceleration,
25-
Dogleg
25+
Dogleg, NonlinearSolveForwardDiffCache
2626
using SciMLBase: SciMLBase, AbstractNonlinearProblem, NLStats, ReturnCode,
2727
NonlinearFunction,
2828
NonlinearLeastSquaresProblem, NonlinearProblem, NoSpecialize

lib/NonlinearSolveQuasiNewton/ext/NonlinearSolveQuasiNewtonForwardDiffExt.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
module NonlinearSolveQuasiNewtonForwardDiffExt
22

3-
using CommonSolve: CommonSolve, solve
3+
using CommonSolve: CommonSolve, init
44
using ForwardDiff: ForwardDiff, Dual
5-
using SciMLBase: SciMLBase, AbstractNonlinearProblem, IntervalNonlinearProblem,
6-
NonlinearProblem, NonlinearLeastSquaresProblem, remake
5+
using SciMLBase: SciMLBase, NonlinearProblem, NonlinearLeastSquaresProblem
76

87
using NonlinearSolveBase: NonlinearSolveBase
98

lib/NonlinearSolveSpectralMethods/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ CommonSolve = "0.2.4"
2727
ConcreteStructs = "0.2.3"
2828
DiffEqBase = "6.158.3"
2929
ExplicitImports = "1.5"
30+
ForwardDiff = "0.10.36"
3031
Hwloc = "3"
3132
InteractiveUtils = "<0.0.1, 1"
3233
LineSearch = "0.1.4"

lib/NonlinearSolveSpectralMethods/ext/NonlinearSolveSpectralMethodsForwardDiffExt.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
module NonlinearSolveSpectralMethodsForwardDiffExt
22

3-
using CommonSolve: CommonSolve, solve
3+
using CommonSolve: CommonSolve, init
44
using ForwardDiff: ForwardDiff, Dual
5-
using SciMLBase: SciMLBase, AbstractNonlinearProblem, IntervalNonlinearProblem,
6-
NonlinearProblem, NonlinearLeastSquaresProblem, remake
5+
using SciMLBase: SciMLBase, NonlinearProblem, NonlinearLeastSquaresProblem
76

87
using NonlinearSolveBase: NonlinearSolveBase
98

0 commit comments

Comments
 (0)