Skip to content

Commit 177cf41

Browse files
authored
Merge pull request #300 from ErikQQY/qqy/quality
Add package quality tests
2 parents 295799a + 730059c commit 177cf41

File tree

33 files changed

+458
-345
lines changed

33 files changed

+458
-345
lines changed

Project.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ version = "5.17.0"
44

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

3534
[compat]
36-
ADTypes = "1.13"
37-
Aqua = "0.8.9"
38-
ArrayInterface = "7.18"
35+
ADTypes = "1.14"
36+
Aqua = "0.8.11"
3937
BoundaryValueDiffEqAscher = "1"
4038
BoundaryValueDiffEqCore = "1"
4139
BoundaryValueDiffEqFIRK = "1"
4240
BoundaryValueDiffEqMIRK = "1"
4341
BoundaryValueDiffEqMIRKN = "1"
4442
BoundaryValueDiffEqShooting = "1"
4543
DiffEqBase = "6.167"
46-
DiffEqDevTools = "2.45"
44+
DiffEqDevTools = "2.48"
4745
FastClosures = "0.3.2"
48-
ForwardDiff = "0.10.38, 1"
46+
ForwardDiff = "0.10.38"
4947
Hwloc = "3.3"
5048
InteractiveUtils = "<0.0.1, 1"
51-
JET = "0.9"
49+
JET = "0.9.18"
5250
LinearAlgebra = "1.10"
51+
LinearSolve = "3.9"
5352
NonlinearSolveFirstOrder = "1.3"
5453
ODEInterface = "0.5"
5554
OrdinaryDiffEq = "6.93"
5655
Pkg = "1.10.0"
5756
Random = "1.10"
57+
RecursiveArrayTools = "3.31.2"
5858
ReTestItems = "1.29"
5959
Reexport = "1.2"
6060
SciMLBase = "2.82"

lib/BoundaryValueDiffEqAscher/Project.toml

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,52 +6,41 @@ version = "1.5.0"
66
[deps]
77
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
88
AlmostBlockDiagonals = "a95523ee-d6da-40b5-98cc-27bc505739d5"
9-
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
10-
BandedMatrices = "aae01518-5342-5314-be14-df237901396f"
119
BoundaryValueDiffEqCore = "56b672f2-a5fe-4263-ab2d-da677488eb3a"
1210
ConcreteStructs = "2569d6c7-a4a2-43d3-a901-331e8e4be471"
1311
DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"
1412
DifferentiationInterface = "a0c0ee7d-e4b9-4e03-894e-1c5f64a51d63"
1513
FastClosures = "9aa1b823-49e4-5ca5-8b0f-3971ec8bab6a"
1614
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
1715
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
18-
LinearSolve = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae"
1916
PreallocationTools = "d236fae5-4411-538c-8e31-a6e3d9e00b46"
20-
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
21-
Preferences = "21216c6a-2e73-6563-6e65-726566657250"
2217
RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd"
2318
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
2419
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
2520
Setfield = "efcf1570-3423-57d1-acb7-fd33fddbac46"
26-
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
2721

2822
[compat]
29-
ADTypes = "1.11"
23+
ADTypes = "1.14"
3024
AlmostBlockDiagonals = "0.1.10"
31-
ArrayInterface = "7.18"
32-
BandedMatrices = "1.7.5"
25+
Aqua = "0.8"
3326
BoundaryValueDiffEqCore = "1"
3427
ConcreteStructs = "0.2.3"
35-
DiffEqBase = "6.158.3"
28+
DiffEqBase = "6.167"
3629
DiffEqDevTools = "2.44"
3730
DifferentiationInterface = "0.6.42"
3831
FastClosures = "0.3.2"
39-
ForwardDiff = "0.10.38, 1"
32+
ForwardDiff = "0.10.38"
4033
Hwloc = "3"
4134
InteractiveUtils = "<0.0.1, 1"
42-
JET = "0.9"
35+
JET = "0.9.18"
4336
LinearAlgebra = "1.10"
44-
LinearSolve = "2.36.2, 3"
4537
PreallocationTools = "0.4.24"
46-
PrecompileTools = "1.2"
47-
Preferences = "1.4"
4838
Random = "1.10"
4939
ReTestItems = "1.23.1"
5040
RecursiveArrayTools = "3.27.0"
5141
Reexport = "1.2"
52-
SciMLBase = "2.71"
42+
SciMLBase = "2.82"
5343
Setfield = "1.1.1"
54-
SparseArrays = "1.10"
5544
StaticArrays = "1.9.8"
5645
Test = "1.10"
5746
julia = "1.10"
@@ -65,12 +54,11 @@ DiffEqDevTools = "f3b72e0c-5b89-59e1-b016-84e28bfd966d"
6554
Hwloc = "0e44f5e4-bd66-52a0-8798-143a42290a1d"
6655
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
6756
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
68-
LinearSolve = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae"
6957
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
7058
ReTestItems = "817f1d60-ba6b-4fd5-9520-3cf149f6a823"
7159
RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd"
7260
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
7361
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
7462

7563
[targets]
76-
test = ["Aqua", "DiffEqDevTools", "Hwloc", "InteractiveUtils", "JET", "LinearSolve", "Random", "ReTestItems", "RecursiveArrayTools", "StaticArrays", "Test"]
64+
test = ["Aqua", "DiffEqDevTools", "Hwloc", "InteractiveUtils", "JET", "Random", "ReTestItems", "RecursiveArrayTools", "StaticArrays", "Test"]

lib/BoundaryValueDiffEqAscher/src/algorithms.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ for stage in (1, 2, 3, 4, 5, 6, 7)
1818
- `zeta`: side condition points, should always be provided.
1919
2020
!!! note
21+
2122
For type-stability, the chunksizes for ForwardDiff ADTypes in
2223
`BVPJacobianAlgorithm` must be provided.
2324
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@testitem "Quality Assurance" begin
2+
using Aqua
3+
4+
Aqua.test_all(BoundaryValueDiffEqAscher)
5+
end
6+
7+
@testitem "JET Package Test" begin
8+
using JET
9+
10+
JET.test_package(BoundaryValueDiffEqAscher, target_defined_modules = true)
11+
end

lib/BoundaryValueDiffEqCore/Project.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"
1212
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
1313
LineSearch = "87fe0de2-c867-4266-b59a-2f0a94fc965b"
1414
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
15-
LinearSolve = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae"
1615
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
1716
NonlinearSolveFirstOrder = "5959db7a-ea39-4486-b5fe-2dd0bf03d60d"
1817
PreallocationTools = "d236fae5-4411-538c-8e31-a6e3d9e00b46"
@@ -25,23 +24,23 @@ SparseConnectivityTracer = "9f842d2f-2579-4b1d-911e-f412cf18a3f5"
2524
SparseMatrixColorings = "0a514795-09f3-496d-8182-132a7b665d35"
2625

2726
[compat]
28-
ADTypes = "1.11"
27+
ADTypes = "1.14"
2928
Adapt = "4.1.1"
30-
Aqua = "0.8.9"
29+
Aqua = "0.8"
3130
ArrayInterface = "7.18"
3231
ConcreteStructs = "0.2.3"
33-
DiffEqBase = "6.158.3"
34-
ForwardDiff = "0.10.38, 1"
32+
DiffEqBase = "6.167"
33+
ForwardDiff = "0.10.38"
3534
InteractiveUtils = "<0.0.1, 1"
35+
JET = "0.9.18"
3636
LineSearch = "0.1.4"
3737
LinearAlgebra = "1.10"
38-
LinearSolve = "2.36.2, 3"
3938
Logging = "1.10"
4039
NonlinearSolveFirstOrder = "1.2"
4140
PreallocationTools = "0.4.24"
4241
RecursiveArrayTools = "3.27.0"
4342
Reexport = "1.2"
44-
SciMLBase = "2.71"
43+
SciMLBase = "2.82"
4544
Setfield = "1"
4645
SparseArrays = "1.10"
4746
SparseConnectivityTracer = "0.6.13"
@@ -52,7 +51,8 @@ julia = "1.10"
5251
[extras]
5352
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
5453
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
54+
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
5555
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
5656

5757
[targets]
58-
test = ["Aqua", "InteractiveUtils", "Test"]
58+
test = ["Aqua", "InteractiveUtils", "JET", "Test"]

lib/BoundaryValueDiffEqCore/src/BoundaryValueDiffEqCore.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,18 @@ using SparseMatrixColorings: GreedyColoringAlgorithm
2424
@reexport using NonlinearSolveFirstOrder, SciMLBase
2525

2626
include("types.jl")
27+
include("solution_utils.jl")
2728
include("utils.jl")
2829
include("algorithms.jl")
2930
include("abstract_types.jl")
3031
include("alg_utils.jl")
3132
include("default_nlsolve.jl")
32-
include("misc_utils.jl")
3333
include("calc_errors.jl")
3434

3535
function SciMLBase.__solve(prob::AbstractBVProblem,
3636
alg::AbstractBoundaryValueDiffEqAlgorithm, args...; kwargs...)
37-
cache = init(prob, alg, args...; kwargs...)
38-
return solve!(cache)
37+
cache = SciMLBase.__init(prob, alg, args...; kwargs...)
38+
return SciMLBase.solve!(cache)
3939
end
4040

4141
export AbstractBoundaryValueDiffEqAlgorithm, BVPJacobianAlgorithm

lib/BoundaryValueDiffEqCore/src/utils.jl

Lines changed: 86 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
recursive_length(x::Vector{<:AbstractArray}) = sum(length, x)
2-
recursive_length(x::Vector{<:MaybeDiffCache}) = sum(xᵢ -> length(xᵢ.u), x)
2+
recursive_length(x::Vector{<:MaybeDiffCache}) = sum(xᵢ -> length(xᵢ.du), x)
33

44
function recursive_flatten(x::Vector{<:AbstractArray})
55
y = zero(first(x), recursive_length(x))
@@ -17,7 +17,7 @@ end
1717
end
1818
@views function recursive_flatten_twopoint!(
1919
y::AbstractVector, x::Vector{<:AbstractArray}, sizes)
20-
x_, xiter = Iterators.peel(x)
20+
x_, xiter = first(x), x[2:end]
2121
copyto!(y[1:prod(sizes[1])], x_[1:prod(sizes[1])])
2222
i = prod(sizes[1])
2323
for xᵢ in xiter
@@ -72,12 +72,30 @@ end
7272
return z
7373
end
7474

75+
"""
76+
interval(mesh, t)
77+
78+
Find the interval that `t` belongs to in `mesh`. Assumes that `mesh` is sorted.
79+
"""
80+
function interval(mesh, t)
81+
return clamp(searchsortedfirst(mesh, t) - 1, 1, length(mesh) - 1)
82+
end
83+
7584
## Easier to dispatch
7685
eval_bc_residual(pt, bc::BC, sol, p) where {BC} = eval_bc_residual(pt, bc, sol, p, sol.t)
7786
eval_bc_residual(_, bc::BC, sol, p, t) where {BC} = bc(sol, p, t)
78-
function eval_bc_residual(::TwoPointBVProblem, (bca, bcb)::BC, sol, p, t) where {BC}
79-
ua = sol isa VectorOfArray ? sol[:, 1] : sol(first(t))
80-
ub = sol isa VectorOfArray ? sol[:, end] : sol(last(t))
87+
function eval_bc_residual(
88+
::TwoPointBVProblem, (bca, bcb)::BC, sol::AbstractVectorOfArray, p, t) where {BC}
89+
ua = sol[:, 1]
90+
ub = sol[:, end]
91+
resida = bca(ua, p)
92+
residb = bcb(ub, p)
93+
return (resida, residb)
94+
end
95+
function eval_bc_residual(
96+
::TwoPointBVProblem, (bca, bcb)::BC, sol::AbstractArray, p, t) where {BC}
97+
ua = first(sol)
98+
ub = last(sol)
8199
resida = bca(ua, p)
82100
residb = bcb(ub, p)
83101
return (resida, residb)
@@ -87,18 +105,42 @@ function eval_bc_residual!(resid, pt, bc!::BC, sol, p) where {BC}
87105
return eval_bc_residual!(resid, pt, bc!, sol, p, sol.t)
88106
end
89107
eval_bc_residual!(resid, _, bc!::BC, sol, p, t) where {BC} = bc!(resid, sol, p, t)
90-
@views function eval_bc_residual!(
91-
resid, ::TwoPointBVProblem, (bca!, bcb!)::BC, sol, p, t) where {BC}
92-
ua = sol isa VectorOfArray ? sol[:, 1] : sol(first(t))
93-
ub = sol isa VectorOfArray ? sol[:, end] : sol(last(t))
108+
@views function eval_bc_residual!(resid, ::TwoPointBVProblem, (bca!, bcb!)::BC,
109+
sol::AbstractVectorOfArray, p, t) where {BC}
110+
ua = sol[:, 1]
111+
ub = sol[:, end]
94112
bca!(resid.resida, ua, p)
95113
bcb!(resid.residb, ub, p)
96114
return resid
97115
end
98116
@views function eval_bc_residual!(
99-
resid::Tuple, ::TwoPointBVProblem, (bca!, bcb!)::BC, sol, p, t) where {BC}
100-
ua = sol isa VectorOfArray ? sol[:, 1] : sol(first(t))
101-
ub = sol isa VectorOfArray ? sol[:, end] : sol(last(t))
117+
resid, ::TwoPointBVProblem, (bca!, bcb!)::BC, sol::AbstractArray, p, t) where {BC}
118+
ua = first(sol)
119+
ub = last(sol)
120+
bca!(resid.resida, ua, p)
121+
bcb!(resid.residb, ub, p)
122+
return resid
123+
end
124+
@views function eval_bc_residual!(resid::Tuple, ::TwoPointBVProblem, (bca!, bcb!)::BC,
125+
sol::AbstractVectorOfArray, p, t) where {BC}
126+
ua = sol[:, 1]
127+
ub = sol[:, end]
128+
bca!(resid[1], ua, p)
129+
bcb!(resid[2], ub, p)
130+
return resid
131+
end
132+
@views function eval_bc_residual!(resid::Tuple, ::TwoPointBVProblem, (bca!, bcb!)::BC,
133+
sol::AbstractArray, p, t) where {BC}
134+
ua = first(sol)
135+
ub = last(sol)
136+
bca!(resid[1], ua, p)
137+
bcb!(resid[2], ub, p)
138+
return resid
139+
end
140+
@views function eval_bc_residual!(resid::Tuple, ::TwoPointBVProblem, (bca!, bcb!)::BC,
141+
sol::SciMLBase.ODESolution, p, t) where {BC}
142+
ua = first(sol)
143+
ub = last(sol)
102144
bca!(resid[1], ua, p)
103145
bcb!(resid[2], ub, p)
104146
return resid
@@ -108,14 +150,22 @@ function eval_bc_residual(::StandardSecondOrderBVProblem, bc::BC, y, dy, p, t) w
108150
res_bc = bc(dy, y, p, t)
109151
return res_bc
110152
end
153+
function eval_bc_residual(::TwoPointSecondOrderBVProblem, (bca, bcb)::BC,
154+
sol::AbstractVectorOfArray, p, t) where {BC}
155+
L = length(t)
156+
ua = sol[:, 1]
157+
ub = sol[:, L]
158+
dua = sol[:, L + 1]
159+
dub = sol[:, end]
160+
return vcat(bca(dua, ua, p), bcb(dub, ub, p))
161+
end
111162
function eval_bc_residual(
112-
::TwoPointSecondOrderBVProblem, (bca, bcb)::BC, sol, p, t) where {BC}
113-
M = length(sol[1])
163+
::TwoPointSecondOrderBVProblem, (bca, bcb)::BC, sol::AbstractArray, p, t) where {BC}
114164
L = length(t)
115-
ua = sol isa VectorOfArray ? sol[:, 1] : sol(first(t))[1:M]
116-
ub = sol isa VectorOfArray ? sol[:, L] : sol(last(t))[1:M]
117-
dua = sol isa VectorOfArray ? sol[:, L + 1] : sol(first(t))[(M + 1):end]
118-
dub = sol isa VectorOfArray ? sol[:, end] : sol(last(t))[(M + 1):end]
165+
ua = first(sol)
166+
ub = sol[L]
167+
dua = sol[L + 1]
168+
dub = last(sol)
119169
return vcat(bca(dua, ua, p), bcb(dub, ub, p))
120170
end
121171

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

141-
function eval_bc_residual!(
142-
resid, ::TwoPointSecondOrderBVProblem, (bca!, bcb!)::BC, sol, p, t) where {BC}
143-
M = length(sol[1])
191+
function eval_bc_residual!(resid, ::TwoPointSecondOrderBVProblem, (bca!, bcb!)::BC,
192+
sol::AbstractVectorOfArray, p, t) where {BC}
193+
L = length(t)
194+
ua = sol[:, 1]
195+
ub = sol[:, L]
196+
dua = sol[:, L + 1]
197+
dub = sol[:, end]
198+
bca!(resid[1], dua, ua, p)
199+
bcb!(resid[2], dub, ub, p)
200+
end
201+
function eval_bc_residual!(resid, ::TwoPointSecondOrderBVProblem,
202+
(bca!, bcb!)::BC, sol::AbstractArray, p, t) where {BC}
144203
L = length(t)
145-
ua = sol isa VectorOfArray ? sol[:, 1] : sol(first(t))[1:M]
146-
ub = sol isa VectorOfArray ? sol[:, L] : sol(last(t))[1:M]
147-
dua = sol isa VectorOfArray ? sol[:, L + 1] : sol(first(t))[(M + 1):end]
148-
dub = sol isa VectorOfArray ? sol[:, end] : sol(last(t))[(M + 1):end]
204+
ua = first(sol)
205+
ub = sol[L]
206+
dua = sol[L + 1]
207+
dub = last(sol)
149208
bca!(resid[1], dua, ua, p)
150209
bcb!(resid[2], dub, ub, p)
151210
end
@@ -169,6 +228,7 @@ function __resize!(x::AbstractVector{<:AbstractArray}, n, M)
169228
end
170229

171230
__resize!(::Nothing, n, _) = nothing
231+
__resize!(::Nothing, n, _, _) = nothing
172232

173233
function __resize!(x::AbstractVector{<:MaybeDiffCache}, n, M)
174234
N = n - length(x)
@@ -284,6 +344,7 @@ end
284344
end
285345

286346
@inline __ones_like(args...) = __fill_like(1, args...)
347+
@inline __zeros_like(args...) = __fill_like(0, args...)
287348

288349
@inline __safe_vec(x) = vec(x)
289350
@inline __safe_vec(x::Tuple) = mapreduce(__safe_vec, vcat, x)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@testitem "Quality Assurance" begin
2+
using Aqua
3+
4+
Aqua.test_all(BoundaryValueDiffEqCore)
5+
end
6+
7+
@testitem "JET Package Test" begin
8+
using JET
9+
10+
JET.test_package(BoundaryValueDiffEqCore, target_defined_modules = true)
11+
end

0 commit comments

Comments
 (0)