Skip to content

Add package quality tests #300

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Apr 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ version = "5.17.0"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
BoundaryValueDiffEqAscher = "7227322d-7511-4e07-9247-ad6ff830280e"
BoundaryValueDiffEqCore = "56b672f2-a5fe-4263-ab2d-da677488eb3a"
BoundaryValueDiffEqFIRK = "85d9eb09-370e-4000-bb32-543851f73618"
Expand Down Expand Up @@ -33,28 +32,29 @@ ODEInterface = "54ca160b-1b9f-5127-a996-1867f4bc2a2c"
BoundaryValueDiffEqODEInterfaceExt = "ODEInterface"

[compat]
ADTypes = "1.13"
Aqua = "0.8.9"
ArrayInterface = "7.18"
ADTypes = "1.14"
Aqua = "0.8.11"
BoundaryValueDiffEqAscher = "1"
BoundaryValueDiffEqCore = "1"
BoundaryValueDiffEqFIRK = "1"
BoundaryValueDiffEqMIRK = "1"
BoundaryValueDiffEqMIRKN = "1"
BoundaryValueDiffEqShooting = "1"
DiffEqBase = "6.167"
DiffEqDevTools = "2.45"
DiffEqDevTools = "2.48"
FastClosures = "0.3.2"
ForwardDiff = "0.10.38, 1"
ForwardDiff = "0.10.38"
Hwloc = "3.3"
InteractiveUtils = "<0.0.1, 1"
JET = "0.9"
JET = "0.9.18"
LinearAlgebra = "1.10"
LinearSolve = "3.9"
NonlinearSolveFirstOrder = "1.3"
ODEInterface = "0.5"
OrdinaryDiffEq = "6.93"
Pkg = "1.10.0"
Random = "1.10"
RecursiveArrayTools = "3.31.2"
ReTestItems = "1.29"
Reexport = "1.2"
SciMLBase = "2.82"
Expand Down
26 changes: 7 additions & 19 deletions lib/BoundaryValueDiffEqAscher/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,52 +6,41 @@ version = "1.5.0"
[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
AlmostBlockDiagonals = "a95523ee-d6da-40b5-98cc-27bc505739d5"
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
BandedMatrices = "aae01518-5342-5314-be14-df237901396f"
BoundaryValueDiffEqCore = "56b672f2-a5fe-4263-ab2d-da677488eb3a"
ConcreteStructs = "2569d6c7-a4a2-43d3-a901-331e8e4be471"
DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"
DifferentiationInterface = "a0c0ee7d-e4b9-4e03-894e-1c5f64a51d63"
FastClosures = "9aa1b823-49e4-5ca5-8b0f-3971ec8bab6a"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
LinearSolve = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae"
PreallocationTools = "d236fae5-4411-538c-8e31-a6e3d9e00b46"
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
Preferences = "21216c6a-2e73-6563-6e65-726566657250"
RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
Setfield = "efcf1570-3423-57d1-acb7-fd33fddbac46"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

[compat]
ADTypes = "1.11"
ADTypes = "1.14"
AlmostBlockDiagonals = "0.1.10"
ArrayInterface = "7.18"
BandedMatrices = "1.7.5"
Aqua = "0.8"
BoundaryValueDiffEqCore = "1"
ConcreteStructs = "0.2.3"
DiffEqBase = "6.158.3"
DiffEqBase = "6.167"
DiffEqDevTools = "2.44"
DifferentiationInterface = "0.6.42"
FastClosures = "0.3.2"
ForwardDiff = "0.10.38, 1"
ForwardDiff = "0.10.38"
Hwloc = "3"
InteractiveUtils = "<0.0.1, 1"
JET = "0.9"
JET = "0.9.18"
LinearAlgebra = "1.10"
LinearSolve = "2.36.2, 3"
PreallocationTools = "0.4.24"
PrecompileTools = "1.2"
Preferences = "1.4"
Random = "1.10"
ReTestItems = "1.23.1"
RecursiveArrayTools = "3.27.0"
Reexport = "1.2"
SciMLBase = "2.71"
SciMLBase = "2.82"
Setfield = "1.1.1"
SparseArrays = "1.10"
StaticArrays = "1.9.8"
Test = "1.10"
julia = "1.10"
Expand All @@ -65,12 +54,11 @@ DiffEqDevTools = "f3b72e0c-5b89-59e1-b016-84e28bfd966d"
Hwloc = "0e44f5e4-bd66-52a0-8798-143a42290a1d"
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
LinearSolve = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
ReTestItems = "817f1d60-ba6b-4fd5-9520-3cf149f6a823"
RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Aqua", "DiffEqDevTools", "Hwloc", "InteractiveUtils", "JET", "LinearSolve", "Random", "ReTestItems", "RecursiveArrayTools", "StaticArrays", "Test"]
test = ["Aqua", "DiffEqDevTools", "Hwloc", "InteractiveUtils", "JET", "Random", "ReTestItems", "RecursiveArrayTools", "StaticArrays", "Test"]
1 change: 1 addition & 0 deletions lib/BoundaryValueDiffEqAscher/src/algorithms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ for stage in (1, 2, 3, 4, 5, 6, 7)
- `zeta`: side condition points, should always be provided.

!!! note

For type-stability, the chunksizes for ForwardDiff ADTypes in
`BVPJacobianAlgorithm` must be provided.

Expand Down
11 changes: 11 additions & 0 deletions lib/BoundaryValueDiffEqAscher/test/qa_tests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@testitem "Quality Assurance" begin
using Aqua

Aqua.test_all(BoundaryValueDiffEqAscher)
end

@testitem "JET Package Test" begin
using JET

JET.test_package(BoundaryValueDiffEqAscher, target_defined_modules = true)
end
16 changes: 8 additions & 8 deletions lib/BoundaryValueDiffEqCore/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
LineSearch = "87fe0de2-c867-4266-b59a-2f0a94fc965b"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
LinearSolve = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
NonlinearSolveFirstOrder = "5959db7a-ea39-4486-b5fe-2dd0bf03d60d"
PreallocationTools = "d236fae5-4411-538c-8e31-a6e3d9e00b46"
Expand All @@ -25,23 +24,23 @@ SparseConnectivityTracer = "9f842d2f-2579-4b1d-911e-f412cf18a3f5"
SparseMatrixColorings = "0a514795-09f3-496d-8182-132a7b665d35"

[compat]
ADTypes = "1.11"
ADTypes = "1.14"
Adapt = "4.1.1"
Aqua = "0.8.9"
Aqua = "0.8"
ArrayInterface = "7.18"
ConcreteStructs = "0.2.3"
DiffEqBase = "6.158.3"
ForwardDiff = "0.10.38, 1"
DiffEqBase = "6.167"
ForwardDiff = "0.10.38"
InteractiveUtils = "<0.0.1, 1"
JET = "0.9.18"
LineSearch = "0.1.4"
LinearAlgebra = "1.10"
LinearSolve = "2.36.2, 3"
Logging = "1.10"
NonlinearSolveFirstOrder = "1.2"
PreallocationTools = "0.4.24"
RecursiveArrayTools = "3.27.0"
Reexport = "1.2"
SciMLBase = "2.71"
SciMLBase = "2.82"
Setfield = "1"
SparseArrays = "1.10"
SparseConnectivityTracer = "0.6.13"
Expand All @@ -52,7 +51,8 @@ julia = "1.10"
[extras]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Aqua", "InteractiveUtils", "Test"]
test = ["Aqua", "InteractiveUtils", "JET", "Test"]
6 changes: 3 additions & 3 deletions lib/BoundaryValueDiffEqCore/src/BoundaryValueDiffEqCore.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ using SparseMatrixColorings: GreedyColoringAlgorithm
@reexport using NonlinearSolveFirstOrder, SciMLBase

include("types.jl")
include("solution_utils.jl")
include("utils.jl")
include("algorithms.jl")
include("abstract_types.jl")
include("alg_utils.jl")
include("default_nlsolve.jl")
include("misc_utils.jl")
include("calc_errors.jl")

function SciMLBase.__solve(prob::AbstractBVProblem,
alg::AbstractBoundaryValueDiffEqAlgorithm, args...; kwargs...)
cache = init(prob, alg, args...; kwargs...)
return solve!(cache)
cache = SciMLBase.__init(prob, alg, args...; kwargs...)
return SciMLBase.solve!(cache)
end

export AbstractBoundaryValueDiffEqAlgorithm, BVPJacobianAlgorithm
Expand Down
111 changes: 86 additions & 25 deletions lib/BoundaryValueDiffEqCore/src/utils.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
recursive_length(x::Vector{<:AbstractArray}) = sum(length, x)
recursive_length(x::Vector{<:MaybeDiffCache}) = sum(xᵢ -> length(xᵢ.u), x)
recursive_length(x::Vector{<:MaybeDiffCache}) = sum(xᵢ -> length(xᵢ.du), x)

function recursive_flatten(x::Vector{<:AbstractArray})
y = zero(first(x), recursive_length(x))
Expand All @@ -17,7 +17,7 @@ end
end
@views function recursive_flatten_twopoint!(
y::AbstractVector, x::Vector{<:AbstractArray}, sizes)
x_, xiter = Iterators.peel(x)
x_, xiter = first(x), x[2:end]
copyto!(y[1:prod(sizes[1])], x_[1:prod(sizes[1])])
i = prod(sizes[1])
for xᵢ in xiter
Expand Down Expand Up @@ -72,12 +72,30 @@ end
return z
end

"""
interval(mesh, t)

Find the interval that `t` belongs to in `mesh`. Assumes that `mesh` is sorted.
"""
function interval(mesh, t)
return clamp(searchsortedfirst(mesh, t) - 1, 1, length(mesh) - 1)
end

## Easier to dispatch
eval_bc_residual(pt, bc::BC, sol, p) where {BC} = eval_bc_residual(pt, bc, sol, p, sol.t)
eval_bc_residual(_, bc::BC, sol, p, t) where {BC} = bc(sol, p, t)
function eval_bc_residual(::TwoPointBVProblem, (bca, bcb)::BC, sol, p, t) where {BC}
ua = sol isa VectorOfArray ? sol[:, 1] : sol(first(t))
ub = sol isa VectorOfArray ? sol[:, end] : sol(last(t))
function eval_bc_residual(
::TwoPointBVProblem, (bca, bcb)::BC, sol::AbstractVectorOfArray, p, t) where {BC}
ua = sol[:, 1]
ub = sol[:, end]
resida = bca(ua, p)
residb = bcb(ub, p)
return (resida, residb)
end
function eval_bc_residual(
::TwoPointBVProblem, (bca, bcb)::BC, sol::AbstractArray, p, t) where {BC}
ua = first(sol)
ub = last(sol)
resida = bca(ua, p)
residb = bcb(ub, p)
return (resida, residb)
Expand All @@ -87,18 +105,42 @@ function eval_bc_residual!(resid, pt, bc!::BC, sol, p) where {BC}
return eval_bc_residual!(resid, pt, bc!, sol, p, sol.t)
end
eval_bc_residual!(resid, _, bc!::BC, sol, p, t) where {BC} = bc!(resid, sol, p, t)
@views function eval_bc_residual!(
resid, ::TwoPointBVProblem, (bca!, bcb!)::BC, sol, p, t) where {BC}
ua = sol isa VectorOfArray ? sol[:, 1] : sol(first(t))
ub = sol isa VectorOfArray ? sol[:, end] : sol(last(t))
@views function eval_bc_residual!(resid, ::TwoPointBVProblem, (bca!, bcb!)::BC,
sol::AbstractVectorOfArray, p, t) where {BC}
ua = sol[:, 1]
ub = sol[:, end]
bca!(resid.resida, ua, p)
bcb!(resid.residb, ub, p)
return resid
end
@views function eval_bc_residual!(
resid::Tuple, ::TwoPointBVProblem, (bca!, bcb!)::BC, sol, p, t) where {BC}
ua = sol isa VectorOfArray ? sol[:, 1] : sol(first(t))
ub = sol isa VectorOfArray ? sol[:, end] : sol(last(t))
resid, ::TwoPointBVProblem, (bca!, bcb!)::BC, sol::AbstractArray, p, t) where {BC}
ua = first(sol)
ub = last(sol)
bca!(resid.resida, ua, p)
bcb!(resid.residb, ub, p)
return resid
end
@views function eval_bc_residual!(resid::Tuple, ::TwoPointBVProblem, (bca!, bcb!)::BC,
sol::AbstractVectorOfArray, p, t) where {BC}
ua = sol[:, 1]
ub = sol[:, end]
bca!(resid[1], ua, p)
bcb!(resid[2], ub, p)
return resid
end
@views function eval_bc_residual!(resid::Tuple, ::TwoPointBVProblem, (bca!, bcb!)::BC,
sol::AbstractArray, p, t) where {BC}
ua = first(sol)
ub = last(sol)
bca!(resid[1], ua, p)
bcb!(resid[2], ub, p)
return resid
end
@views function eval_bc_residual!(resid::Tuple, ::TwoPointBVProblem, (bca!, bcb!)::BC,
sol::SciMLBase.ODESolution, p, t) where {BC}
ua = first(sol)
ub = last(sol)
bca!(resid[1], ua, p)
bcb!(resid[2], ub, p)
return resid
Expand All @@ -108,14 +150,22 @@ function eval_bc_residual(::StandardSecondOrderBVProblem, bc::BC, y, dy, p, t) w
res_bc = bc(dy, y, p, t)
return res_bc
end
function eval_bc_residual(::TwoPointSecondOrderBVProblem, (bca, bcb)::BC,
sol::AbstractVectorOfArray, p, t) where {BC}
L = length(t)
ua = sol[:, 1]
ub = sol[:, L]
dua = sol[:, L + 1]
dub = sol[:, end]
return vcat(bca(dua, ua, p), bcb(dub, ub, p))
end
function eval_bc_residual(
::TwoPointSecondOrderBVProblem, (bca, bcb)::BC, sol, p, t) where {BC}
M = length(sol[1])
::TwoPointSecondOrderBVProblem, (bca, bcb)::BC, sol::AbstractArray, p, t) where {BC}
L = length(t)
ua = sol isa VectorOfArray ? sol[:, 1] : sol(first(t))[1:M]
ub = sol isa VectorOfArray ? sol[:, L] : sol(last(t))[1:M]
dua = sol isa VectorOfArray ? sol[:, L + 1] : sol(first(t))[(M + 1):end]
dub = sol isa VectorOfArray ? sol[:, end] : sol(last(t))[(M + 1):end]
ua = first(sol)
ub = sol[L]
dua = sol[L + 1]
dub = last(sol)
return vcat(bca(dua, ua, p), bcb(dub, ub, p))
end

Expand All @@ -138,14 +188,23 @@ function eval_bc_residual!(resid::AbstractArray{<:AbstractArray},
copyto!(resid[2], res_bc[(M + 1):end])
end

function eval_bc_residual!(
resid, ::TwoPointSecondOrderBVProblem, (bca!, bcb!)::BC, sol, p, t) where {BC}
M = length(sol[1])
function eval_bc_residual!(resid, ::TwoPointSecondOrderBVProblem, (bca!, bcb!)::BC,
sol::AbstractVectorOfArray, p, t) where {BC}
L = length(t)
ua = sol[:, 1]
ub = sol[:, L]
dua = sol[:, L + 1]
dub = sol[:, end]
bca!(resid[1], dua, ua, p)
bcb!(resid[2], dub, ub, p)
end
function eval_bc_residual!(resid, ::TwoPointSecondOrderBVProblem,
(bca!, bcb!)::BC, sol::AbstractArray, p, t) where {BC}
L = length(t)
ua = sol isa VectorOfArray ? sol[:, 1] : sol(first(t))[1:M]
ub = sol isa VectorOfArray ? sol[:, L] : sol(last(t))[1:M]
dua = sol isa VectorOfArray ? sol[:, L + 1] : sol(first(t))[(M + 1):end]
dub = sol isa VectorOfArray ? sol[:, end] : sol(last(t))[(M + 1):end]
ua = first(sol)
ub = sol[L]
dua = sol[L + 1]
dub = last(sol)
bca!(resid[1], dua, ua, p)
bcb!(resid[2], dub, ub, p)
end
Expand All @@ -169,6 +228,7 @@ function __resize!(x::AbstractVector{<:AbstractArray}, n, M)
end

__resize!(::Nothing, n, _) = nothing
__resize!(::Nothing, n, _, _) = nothing

function __resize!(x::AbstractVector{<:MaybeDiffCache}, n, M)
N = n - length(x)
Expand Down Expand Up @@ -284,6 +344,7 @@ end
end

@inline __ones_like(args...) = __fill_like(1, args...)
@inline __zeros_like(args...) = __fill_like(0, args...)

@inline __safe_vec(x) = vec(x)
@inline __safe_vec(x::Tuple) = mapreduce(__safe_vec, vcat, x)
Expand Down
11 changes: 11 additions & 0 deletions lib/BoundaryValueDiffEqCore/test/qa_tests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@testitem "Quality Assurance" begin
using Aqua

Aqua.test_all(BoundaryValueDiffEqCore)
end

@testitem "JET Package Test" begin
using JET

JET.test_package(BoundaryValueDiffEqCore, target_defined_modules = true)
end
Loading
Loading