Skip to content

Commit

Permalink
fix: QA for NonlinearSolveBase
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed Oct 8, 2024
1 parent 8cf9899 commit 4590181
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 7 deletions.
16 changes: 16 additions & 0 deletions lib/NonlinearSolveBase/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,36 @@ NonlinearSolveBaseSparseArraysExt = "SparseArrays"

[compat]
ADTypes = "1.9"
Aqua = "0.8.7"
ArrayInterface = "7.9"
CommonSolve = "0.2.4"
Compat = "4.15"
ConcreteStructs = "0.2.3"
DiffEqBase = "6.149"
DifferentiationInterface = "0.6.1"
EnzymeCore = "0.8"
ExplicitImports = "1.10.1"
FastClosures = "0.3"
ForwardDiff = "0.10.36"
FunctionProperties = "0.1.2"
InteractiveUtils = "<0.0.1, 1"
LinearAlgebra = "1.10"
Markdown = "1.10"
RecursiveArrayTools = "3"
SciMLBase = "2.50"
SparseArrays = "1.10"
StaticArraysCore = "1.4"
Test = "1.10"
julia = "1.10"

[extras]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"
ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Aqua", "DiffEqBase", "ExplicitImports", "ForwardDiff", "InteractiveUtils", "SparseArrays", "Test"]
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module NonlinearSolveBaseForwardDiffExt
using ADTypes: ADTypes, AutoForwardDiff, AutoPolyesterForwardDiff
using ArrayInterface: ArrayInterface
using CommonSolve: solve
using DifferentiationInterface: DifferentiationInterface, Constant
using DifferentiationInterface: DifferentiationInterface
using FastClosures: @closure
using ForwardDiff: ForwardDiff, Dual
using LinearAlgebra: mul!
Expand Down
3 changes: 2 additions & 1 deletion lib/NonlinearSolveBase/src/NonlinearSolveBase.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
module NonlinearSolveBase

using ADTypes: ADTypes, AbstractADType, ForwardMode, ReverseMode
using ADTypes: ADTypes, AbstractADType
using ArrayInterface: ArrayInterface
using CommonSolve: CommonSolve
using Compat: @compat
using ConcreteStructs: @concrete
using DifferentiationInterface: DifferentiationInterface
Expand Down
10 changes: 5 additions & 5 deletions lib/NonlinearSolveBase/src/termination_conditions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ function update_u!!(cache::NonlinearTerminationModeCache, u)
end
end

function SciMLBase.init(
du, u, mode::AbstractNonlinearTerminationMode, saved_value_prototype...;
abstol = nothing, reltol = nothing, kwargs...)
function CommonSolve.init(
::AbstractNonlinearProblem, mode::AbstractNonlinearTerminationMode, du, u,
saved_value_prototype...; abstol = nothing, reltol = nothing, kwargs...)
T = promote_type(eltype(du), eltype(u))
abstol = get_tolerance(u, abstol, T)
reltol = get_tolerance(u, reltol, T)
Expand Down Expand Up @@ -273,11 +273,11 @@ function init_termination_cache(
prob, abstol, reltol, du, u, default_termination_mode(prob, callee), callee)
end

function init_termination_cache(::AbstractNonlinearProblem, abstol, reltol, du,
function init_termination_cache(prob::AbstractNonlinearProblem, abstol, reltol, du,
u, tc::AbstractNonlinearTerminationMode, ::Val)
T = promote_type(eltype(du), eltype(u))
abstol = get_tolerance(u, abstol, T)
reltol = get_tolerance(u, reltol, T)
cache = SciMLBase.init(du, u, tc; abstol, reltol)
cache = CommonSolve.init(prob, tc, du, u; abstol, reltol)
return abstol, reltol, cache
end
23 changes: 23 additions & 0 deletions lib/NonlinearSolveBase/test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1 +1,24 @@
using InteractiveUtils, Test

@info sprint(InteractiveUtils.versioninfo)

# Changing any code here triggers all the other tests to be run. So we intentionally
# keep the tests here minimal.
@testset "NonlinearSolveBase.jl" begin
@testset "Aqua" begin
using Aqua, NonlinearSolveBase

Aqua.test_all(NonlinearSolveBase; piracies = false, ambiguities = false)
Aqua.test_piracies(NonlinearSolveBase)
Aqua.test_ambiguities(NonlinearSolveBase; recursive = false)
end

@testset "Explicit Imports" begin
import ForwardDiff, SparseArrays, DiffEqBase
using ExplicitImports, NonlinearSolveBase

@test check_no_implicit_imports(NonlinearSolveBase; skip = (Base, Core)) === nothing
@test check_no_stale_explicit_imports(NonlinearSolveBase) === nothing
@test check_all_qualified_accesses_via_owners(NonlinearSolveBase) === nothing
end
end

0 comments on commit 4590181

Please sign in to comment.