Skip to content

Commit 66e0ca8

Browse files
Merge #134
134: Fix broken aqua tests r=charleskawczynski a=charleskawczynski This PR fixes the broken aqua tests. Co-authored-by: Charles Kawczynski <[email protected]>
2 parents 1a1df0d + b5faa7d commit 66e0ca8

File tree

6 files changed

+43
-55
lines changed

6 files changed

+43
-55
lines changed

src/ClimaTimeSteppers.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ include("solvers/newtons_method.jl")
9494
include("solvers/imex_ark_tableaus.jl")
9595
include("solvers/imex_ark.jl")
9696

97+
n_stages_ntuple(::Type{<:NTuple{Nstages}}) where {Nstages} = Nstages
98+
9799
# Include concrete implementations
98100
include("solvers/multirate.jl")
99101
include("solvers/lsrk.jl")

src/solvers/lsrk.jl

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,18 @@ abstract type LowStorageRungeKutta2N <: DistributedODEAlgorithm end
1919
2020
Storage for the tableau of a [`LowStorageRungeKutta2N`](@ref) algorithm.
2121
"""
22-
struct LowStorageRungeKutta2NTableau{Nstages, RT}
22+
struct LowStorageRungeKutta2NTableau{T <: NTuple}
2323
"low storage RK coefficient vector A (rhs scaling)"
24-
A::NTuple{Nstages, RT}
24+
A::T
2525
"low storage RK coefficient vector B (rhs add in scaling)"
26-
B::NTuple{Nstages, RT}
26+
B::T
2727
"low storage RK coefficient vector C (time scaling)"
28-
C::NTuple{Nstages, RT}
28+
C::T
2929
end
30+
n_stages(::LowStorageRungeKutta2NTableau{T}) where {T} = n_stages_ntuple(T)
3031

31-
struct LowStorageRungeKutta2NIncCache{Nstages, RT, A}
32-
tableau::LowStorageRungeKutta2NTableau{Nstages, RT}
32+
struct LowStorageRungeKutta2NIncCache{T <: LowStorageRungeKutta2NTableau, A}
33+
tableau::T
3334
du::A
3435
end
3536

@@ -40,7 +41,7 @@ function init_cache(prob::DiffEqBase.ODEProblem, alg::LowStorageRungeKutta2N; kw
4041
return LowStorageRungeKutta2NIncCache(tableau(alg, eltype(du)), du)
4142
end
4243

43-
n_stages(::LowStorageRungeKutta2NIncCache{N}) where {N} = N
44+
n_stages(cache::LowStorageRungeKutta2NIncCache) = n_stages(cache.tableau)
4445

4546
function step_u!(int, cache::LowStorageRungeKutta2NIncCache)
4647
(; C, A, B) = cache.tableau

src/solvers/mis.jl

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,19 @@ The available implementations are:
1616
"""
1717
abstract type MultirateInfinitesimalStep <: DistributedODEAlgorithm end
1818

19-
20-
struct MultirateInfinitesimalStepTableau{Nstages, Nstages², RT}
21-
α::SArray{NTuple{2, Nstages}, RT, 2, Nstages²}
22-
β::SArray{NTuple{2, Nstages}, RT, 2, Nstages²}
23-
γ::SArray{NTuple{2, Nstages}, RT, 2, Nstages²}
24-
d::SArray{NTuple{1, Nstages}, RT, 1, Nstages}
25-
c::SArray{NTuple{1, Nstages}, RT, 1, Nstages}
26-
::SArray{NTuple{1, Nstages}, RT, 1, Nstages}
19+
const T1Type = SArray{NTuple{1, Nstages}, RT, 1, Nstages} where {Nstages, RT}
20+
const T2Type = SArray{NTuple{2, Nstages}, RT, 2, Nstages²} where {Nstages, RT, Nstages²}
21+
22+
struct MultirateInfinitesimalStepTableau{T2 <: T2Type, T1 <: T1Type}
23+
α::T2
24+
β::T2
25+
γ::T2
26+
d::T1
27+
c::T1
28+
::T1
2729
end
30+
n_stages(::MultirateInfinitesimalStepTableau{T2, T1}) where {T2, T1} = n_stages_ntuple(T1)
31+
2832
function MultirateInfinitesimalStepTableau(α, β, γ)
2933
d = SVector(sum(β, dims = 2)) # KW2014 (2)
3034
# c = (I - α - γ) \ d
@@ -41,15 +45,15 @@ function MultirateInfinitesimalStepTableau(α, β, γ)
4145
end
4246

4347

44-
struct MultirateInfinitesimalStepCache{Nstages, A, T <: MultirateInfinitesimalStepTableau}
48+
struct MultirateInfinitesimalStepCache{T, TT <: MultirateInfinitesimalStepTableau}
4549
"difference between stage and initial value ``U^{(i)} - u``"
46-
ΔU::NTuple{Nstages, A}
50+
ΔU::T
4751
"evaluated slow part of each stage ``f_slow(U^{(i)})``"
48-
F::NTuple{Nstages, A}
49-
tableau::T
52+
F::T
53+
tableau::TT
5054
end
5155

52-
n_stages(::MultirateInfinitesimalStepCache{Nstages}) where {Nstages} = Nstages
56+
n_stages(cache::MultirateInfinitesimalStepCache) = n_stages(cache.tableau)
5357

5458
function init_cache(
5559
prob::DiffEqBase.AbstractODEProblem{uType, tType, true},

src/solvers/ssprk.jl

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,27 @@ The available implementations are:
1515
"""
1616
abstract type StrongStabilityPreservingRungeKutta <: DistributedODEAlgorithm end
1717

18-
struct StrongStabilityPreservingRungeKuttaTableau{Nstages, RT}
18+
struct StrongStabilityPreservingRungeKuttaTableau{T}
1919
"Storage RK coefficient vector A1 (rhs scaling of u)"
20-
A1::NTuple{Nstages, RT}
20+
A1::T
2121
"Storage RK coefficient vector A2 (rhs scaling of U)"
22-
A2::NTuple{Nstages, RT}
22+
A2::T
2323
"Storage RK coefficient vector B (rhs add in scaling)"
24-
B::NTuple{Nstages, RT}
24+
B::T
2525
"Storage RK coefficient vector C (time scaling)"
26-
C::NTuple{Nstages, RT}
26+
C::T
2727
end
28+
n_stages(::StrongStabilityPreservingRungeKuttaTableau{T}) where {T} = n_stages_ntuple(T)
2829

29-
struct StrongStabilityPreservingRungeKuttaCache{Nstages, RT, A}
30-
tableau::StrongStabilityPreservingRungeKuttaTableau{Nstages, RT}
30+
struct StrongStabilityPreservingRungeKuttaCache{T <: StrongStabilityPreservingRungeKuttaTableau, A}
31+
tableau::T
3132
"Storage for RHS during the `StrongStabilityPreservingRungeKutta` update"
3233
fU::A
3334
"Storage for the stage state during the `StrongStabilityPreservingRungeKutta` update"
3435
U::A
3536
end
3637

37-
n_stages(::StrongStabilityPreservingRungeKuttaCache{Nstages}) where {Nstages} = Nstages
38+
n_stages(cache::StrongStabilityPreservingRungeKuttaCache) = n_stages(cache.tableau)
3839

3940
function init_cache(prob::DiffEqBase.AbstractODEProblem, alg::StrongStabilityPreservingRungeKutta; kwargs...)
4041

src/solvers/wickerskamarock.jl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@ Available implementations are:
1414
"""
1515
abstract type WickerSkamarockRungeKutta <: DistributedODEAlgorithm end
1616

17-
struct WickerSkamarockRungeKuttaTableau{Nstages, RT}
17+
struct WickerSkamarockRungeKuttaTableau{T <: NTuple}
1818
"Time-scaling coefficients c"
19-
c::NTuple{Nstages, RT}
19+
c::T
2020
end
21+
n_stages(::WickerSkamarockRungeKuttaTableau{T}) where {T} = n_stages_ntuple(T)
2122

22-
struct WickerSkamarockRungeKuttaCache{Nstages, RT, A}
23-
tableau::WickerSkamarockRungeKuttaTableau{Nstages, RT}
23+
struct WickerSkamarockRungeKuttaCache{T <: WickerSkamarockRungeKuttaTableau, A}
24+
tableau::T
2425
U::A
2526
F::A
2627
end
@@ -30,7 +31,7 @@ function init_cache(prob::DiffEqBase.ODEProblem, alg::WickerSkamarockRungeKutta;
3031
return WickerSkamarockRungeKuttaCache(tableau(alg, eltype(F)), U, F)
3132
end
3233

33-
n_stages(::WickerSkamarockRungeKuttaCache{Nstages}) where {Nstages} = Nstages
34+
n_stages(cache::WickerSkamarockRungeKuttaCache) = n_stages(cache.tableau)
3435

3536

3637
function init_inner(prob, outercache::WickerSkamarockRungeKuttaCache, dt)

test/aqua.jl

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,9 @@ using ClimaTimeSteppers
55
@testset "Aqua tests" begin
66
# This tests that we don't accidentally run into
77
# https://github.com/JuliaLang/julia/issues/29393
8-
9-
# Aqua.test_unbound_args(ClimaTimeSteppers)
10-
# Fails with:
11-
#=
12-
Expression: detect_unbound_args_recursively(m) == []
13-
Evaluated: Any[
14-
ClimaTimeSteppers.WickerSkamarockRungeKuttaTableau(c::Tuple{Vararg{RT, Nstages}}) where {Nstages, RT}
15-
in ClimaTimeSteppers at ClimaTimeSteppers.jl/ClimaTimeSteppers.jl/src/solvers/wickerskamarock.jl:18,
16-
ClimaTimeSteppers.LowStorageRungeKutta2NTableau(A::Tuple{Vararg{RT, Nstages}}, B::Tuple{Vararg{RT, Nstages}}, C::Tuple{Vararg{RT, Nstages}}) where {Nstages, RT}
17-
in ClimaTimeSteppers at ClimaTimeSteppers.jl/ClimaTimeSteppers.jl/src/solvers/lsrk.jl:23,
18-
ClimaTimeSteppers.MultirateInfinitesimalStepCache(ΔU::Tuple{Vararg{A, Nstages}}, F::Tuple{Vararg{A, Nstages}}, tableau::T) where {Nstages, A, T<:ClimaTimeSteppers.MultirateInfinitesimalStepTableau}
19-
in ClimaTimeSteppers at ClimaTimeSteppers.jl/ClimaTimeSteppers.jl/src/solvers/mis.jl:45,
20-
ClimaTimeSteppers.StrongStabilityPreservingRungeKuttaTableau(A1::Tuple{Vararg{RT, Nstages}}, A2::Tuple{Vararg{RT, Nstages}}, B::Tuple{Vararg{RT, Nstages}}, C::Tuple{Vararg{RT, Nstages}}) where {Nstages, RT}
21-
in ClimaTimeSteppers at ClimaTimeSteppers.jl/ClimaTimeSteppers.jl/src/solvers/ssprk.jl:19] == Any[]
22-
=#
8+
Aqua.test_unbound_args(ClimaTimeSteppers)
239

2410
# See: https://github.com/SciML/OrdinaryDiffEq.jl/issues/1750
2511
# Test that we're not introducing method ambiguities
2612
@test isempty(Aqua.detect_ambiguities(ClimaTimeSteppers; recursive = true))
27-
28-
# If the number of unbound args is less than the limit below,
29-
# then please lower the limit. We're trying to drive this number
30-
# down to zero.
31-
ua = Aqua.detect_unbound_args_recursively(ClimaTimeSteppers)
32-
@test length(ua) 4
33-
@test_broken length(ua) 4
3413
end

0 commit comments

Comments
 (0)