Skip to content

Commit 1a29122

Browse files
committed
fix: :misc testing
1 parent 6dbc95e commit 1a29122

File tree

5 files changed

+17
-18
lines changed

5 files changed

+17
-18
lines changed

src/NonlinearSolve.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,11 @@ include("algorithms/levenberg_marquardt.jl")
9696
include("algorithms/trust_region.jl")
9797
include("algorithms/extension_algs.jl")
9898

99-
include("internal/forward_diff.jl") # we need to define after the algorithms
100-
10199
include("utils.jl")
102100
include("default.jl")
103101

102+
include("internal/forward_diff.jl") # we need to define after the algorithms
103+
104104
# @setup_workload begin
105105
# nlfuncs = ((NonlinearFunction{false}((u, p) -> u .* u .- p), 0.1),
106106
# (NonlinearFunction{true}((du, u, p) -> du .= u .* u .- p), [0.1]))

src/internal/forward_diff.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ for algType in (
1010
Nothing, AbstractNonlinearSolveAlgorithm, GeneralizedDFSane,
1111
GeneralizedFirstOrderAlgorithm, ApproximateJacobianSolveAlgorithm,
1212
LeastSquaresOptimJL, FastLevenbergMarquardtJL, CMINPACK, NLsolveJL, NLSolversJL,
13-
SpeedMappingJL, FixedPointAccelerationJL, SIAMFANLEquationsJL
13+
SpeedMappingJL, FixedPointAccelerationJL, SIAMFANLEquationsJL,
14+
NonlinearSolvePolyAlgorithm{:NLLS, <:Any}, NonlinearSolvePolyAlgorithm{:NLS, <:Any}
1415
)
1516
@eval function SciMLBase.__solve(
1617
prob::DualNonlinearProblem, alg::$(algType), args...; kwargs...)
@@ -47,7 +48,8 @@ for algType in (
4748
SimpleNonlinearSolve.AbstractSimpleNonlinearSolveAlgorithm,
4849
GeneralizedFirstOrderAlgorithm, ApproximateJacobianSolveAlgorithm,
4950
LeastSquaresOptimJL, FastLevenbergMarquardtJL, CMINPACK, NLsolveJL, NLSolversJL,
50-
SpeedMappingJL, FixedPointAccelerationJL, SIAMFANLEquationsJL
51+
SpeedMappingJL, FixedPointAccelerationJL, SIAMFANLEquationsJL,
52+
NonlinearSolvePolyAlgorithm{:NLLS, <:Any}, NonlinearSolvePolyAlgorithm{:NLS, <:Any}
5153
)
5254
@eval function SciMLBase.__init(
5355
prob::DualNonlinearProblem, alg::$(algType), args...; kwargs...)

src/internal/helpers.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,11 @@ function __construct_extension_f(prob::AbstractNonlinearProblem; alias_u0::Bool
109109
end
110110

111111
function __construct_extension_jac(prob, alg, u0, fu; can_handle_oop::Val = False,
112-
can_handle_scalar::Val = False, kwargs...)
112+
can_handle_scalar::Val = False, autodiff = nothing, kwargs...)
113+
autodiff = select_jacobian_autodiff(prob, autodiff)
114+
113115
Jₚ = JacobianCache(
114-
prob, alg, prob.f, fu, u0, prob.p; stats = empty_nlstats(), kwargs...)
116+
prob, alg, prob.f, fu, u0, prob.p; stats = empty_nlstats(), autodiff, kwargs...)
115117

116118
𝓙 = (can_handle_scalar === False && prob.u0 isa Number) ? @closure(u->[Jₚ(u[1])]) : Jₚ
117119

src/internal/linear_solve.jl

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,7 @@ function (cache::LinearSolverCache)(;
149149
if linres.retcode === ReturnCode.Failure
150150
structured_mat = ArrayInterface.isstructured(cache.lincache.A)
151151
is_gpuarray = ArrayInterface.device(cache.lincache.A) isa ArrayInterface.GPU
152-
if !(cache.linsolve isa QRFactorization{ColumnNorm}) &&
153-
!is_gpuarray &&
152+
if !(cache.linsolve isa QRFactorization{ColumnNorm}) && !is_gpuarray &&
154153
!structured_mat
155154
if verbose
156155
@warn "Potential Rank Deficient Matrix Detected. Attempting to solve using \
@@ -177,15 +176,11 @@ function (cache::LinearSolverCache)(;
177176
return LinearSolveResult(; u = linres.u)
178177
elseif !(cache.linsolve isa QRFactorization{ColumnNorm})
179178
if verbose
180-
if structured_mat
179+
if structured_mat || is_gpuarray
180+
mat_desc = structured_mat ? "Structured" : "GPU"
181181
@warn "Potential Rank Deficient Matrix Detected. But Matrix is \
182-
Structured. Currently, we don't attempt to solve Rank Deficient \
183-
Structured Matrices. Please open an issue at \
184-
https://github.com/SciML/NonlinearSolve.jl"
185-
elseif is_gpuarray
186-
@warn "Potential Rank Deficient Matrix Detected. But Matrix is on GPU. \
187-
Currently, we don't attempt to solve Rank Deficient GPU \
188-
Matrices. Please open an issue at \
182+
$(mat_desc). Currently, we don't attempt to solve Rank Deficient \
183+
$(mat_desc) Matrices. Please open an issue at \
189184
https://github.com/SciML/NonlinearSolve.jl"
190185
end
191186
end

test/misc/aliasing_tests.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99

1010
# If aliasing is not handled properly this will diverge
1111
sol = solve(prob; abstol = 1e-6, alias_u0 = true,
12-
termination_condition = AbsNormTerminationMode())
12+
termination_condition = AbsNormTerminationMode(Base.Fix1(maximum, abs)))
1313

1414
@test sol.u === prob.u0
1515
@test SciMLBase.successful_retcode(sol.retcode)
1616

1717
prob = remake(prob; u0 = copy(u0))
1818

1919
cache = init(prob; abstol = 1e-6, alias_u0 = true,
20-
termination_condition = AbsNormTerminationMode())
20+
termination_condition = AbsNormTerminationMode(Base.Fix1(maximum, abs)))
2121
sol = solve!(cache)
2222

2323
@test sol.u === prob.u0

0 commit comments

Comments
 (0)