Skip to content

Commit 67e0245

Browse files
Merge pull request #1111 from SciML/testsplit
Split QA tests to a separate group
2 parents eded161 + c0bf32c commit 67e0245

File tree

6 files changed

+54
-28
lines changed

6 files changed

+54
-28
lines changed

.github/workflows/CI.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
- Core5
2525
- Core6
2626
- Core7
27+
- QA
2728
- SDE1
2829
- SDE2
2930
- SDE3

src/forward_sensitivity.jl

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ function ODEForwardSensitivityProblem(f::F, args...; kwargs...) where {F}
157157
ODEForwardSensitivityProblem(ODEFunction(f), args...; kwargs...)
158158
end
159159

160-
function ODEForwardSensitivityProblem(prob::ODEProblem; sensealg = ForwardSensitivity(), kwargs...)
160+
function ODEForwardSensitivityProblem(
161+
prob::ODEProblem; sensealg = ForwardSensitivity(), kwargs...)
161162
_ODEForwardSensitivityProblem(
162163
prob.f, state_values(prob), prob.tspan, parameter_values(prob), sensealg; kwargs...)
163164
end
@@ -351,11 +352,10 @@ at time `sol.t[i]`. Note that all the functionality available to ODE solutions
351352
is available in this case, including interpolations and plot recipes (the recipes
352353
will plot the expanded system).
353354
"""
354-
function ODEForwardSensitivityProblem(f::F, u0, tspan, p = nothing;
355-
sensealg = ForwardSensitivity(),
356-
kwargs...) where {F <: DiffEqBase.AbstractODEFunction}
357-
358-
_ODEForwardSensitivityProblem(f,u0,tspan,p,sensealg; kwargs...)
355+
function ODEForwardSensitivityProblem(f::F, u0, tspan, p = nothing;
356+
sensealg = ForwardSensitivity(),
357+
kwargs...) where {F <: DiffEqBase.AbstractODEFunction}
358+
_ODEForwardSensitivityProblem(f, u0, tspan, p, sensealg; kwargs...)
359359
end
360360

361361
# deprecated
@@ -366,8 +366,10 @@ function ODEForwardSensitivityProblem(f::F, u0,
366366
w0 = nothing,
367367
v0 = nothing,
368368
kwargs...) where {F <: DiffEqBase.AbstractODEFunction}
369-
Base.depwarn("The form of this function with `alg` as a positional argument is deprecated. Please use the `sensealg` keyword argument instead.", :ODEForwardSensitivityProblem)
370-
_ODEForwardSensitivityProblem(f,u0,tspan,p,alg; nus,w0,v0,kwargs...)
369+
Base.depwarn(
370+
"The form of this function with `alg` as a positional argument is deprecated. Please use the `sensealg` keyword argument instead.",
371+
:ODEForwardSensitivityProblem)
372+
_ODEForwardSensitivityProblem(f, u0, tspan, p, alg; nus, w0, v0, kwargs...)
371373
end
372374

373375
function _ODEForwardSensitivityProblem(f::F, u0,
@@ -490,7 +492,9 @@ function ODEForwardSensitivityProblem(f::DiffEqBase.AbstractODEFunction, u0,
490492
du0 = zeros(eltype(u0), length(u0), length(p)), # perturbations of initial condition
491493
dp = I(length(p)), # perturbations of parameters
492494
kwargs...)
493-
Base.depwarn("The form of this function with `alg` as a positional argument is deprecated. Please use the `sensealg` keyword argument instead.", :ODEForwardSensitivity)
495+
Base.depwarn(
496+
"The form of this function with `alg` as a positional argument is deprecated. Please use the `sensealg` keyword argument instead.",
497+
:ODEForwardSensitivity)
494498
_ODEForwardSensitivityProblem(f, u0, tspan, p, alg, du0, dp, kwargs...)
495499
end
496500

test/forward.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ probvecmat = ODEForwardSensitivityProblem(fb, [1.0; 1.0], (0.0, 10.0), p,
3737
autojacmat = true))
3838

3939
# tests that the deprecated version still works
40-
dep_prob_const = ODEForwardSensitivityProblem(fb, [1.0; 1.0], (0.0, 10.0), p, ForwardSensitivity())
40+
dep_prob_const = ODEForwardSensitivityProblem(
41+
fb, [1.0; 1.0], (0.0, 10.0), p, ForwardSensitivity())
4142

4243
sol = solve(prob, Tsit5(), abstol = 1e-14, reltol = 1e-14)
4344
@test_broken solve(probInpl, KenCarp4(), abstol = 1e-14, reltol = 1e-14).retcode == :Success
@@ -199,7 +200,8 @@ sol_MM_ForwardDiffSensitivity = solve(prob_MM_ForwardDiffSensitivity,
199200
Rodas4(autodiff = false), reltol = 1e-14,
200201
abstol = 1e-14)
201202

202-
prob_no_MM = ODEForwardSensitivityProblem(f_no_MM, u0, tspan, p, sensealg = ForwardSensitivity())
203+
prob_no_MM = ODEForwardSensitivityProblem(
204+
f_no_MM, u0, tspan, p, sensealg = ForwardSensitivity())
203205
sol_no_MM = solve(prob_no_MM, Rodas4(autodiff = false), reltol = 1e-14, abstol = 1e-14)
204206

205207
sen_MM_ForwardSensitivity = extract_local_sensitivities(sol_MM_ForwardSensitivity, 10.0,

test/noindex_tests.jl

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ end
77
Base.size(x::CustomArray) = size(x.x)
88
Base.axes(x::CustomArray) = axes(x.x)
99
Base.ndims(x::CustomArray) = ndims(x.x)
10-
Base.ndims(::Type{<:CustomArray{T,N}}) where {T,N} = N
10+
Base.ndims(::Type{<:CustomArray{T, N}}) where {T, N} = N
1111
Base.zero(x::CustomArray) = CustomArray(zero(x.x))
12-
Base.zero(::Type{<:CustomArray{T,N}}) where {T,N} = CustomArray(zero(Array{T,N}))
13-
Base.similar(x::CustomArray, dims::Union{Integer, AbstractUnitRange}...) = CustomArray(similar(x.x, dims...))
12+
Base.zero(::Type{<:CustomArray{T, N}}) where {T, N} = CustomArray(zero(Array{T, N}))
13+
function Base.similar(x::CustomArray, dims::Union{Integer, AbstractUnitRange}...)
14+
CustomArray(similar(x.x, dims...))
15+
end
1416
Base.copyto!(x::CustomArray, y::CustomArray) = CustomArray(copyto!(x.x, y.x))
1517
Base.copy(x::CustomArray) = CustomArray(copy(x.x))
1618
Base.length(x::CustomArray) = length(x.x)
@@ -29,22 +31,30 @@ Base.all(f::Function, x::CustomArray; kwargs...) = all(f, x.x; kwargs...)
2931
Base.similar(x::CustomArray, t) = CustomArray(similar(x.x, t))
3032
Base.:(+)(x::CustomArray, y::CustomArray) = CustomArray(x.x + y.x)
3133
Base.:(==)(x::CustomArray, y::CustomArray) = x.x == y.x
32-
Base.:(*)(x::Number, y::CustomArray) = CustomArray(x*y.x)
33-
Base.:(/)(x::CustomArray, y::Number) = CustomArray(x.x/y)
34+
Base.:(*)(x::Number, y::CustomArray) = CustomArray(x * y.x)
35+
Base.:(/)(x::CustomArray, y::Number) = CustomArray(x.x / y)
3436
LinearAlgebra.norm(x::CustomArray) = norm(x.x)
3537
LinearAlgebra.vec(x::CustomArray) = CustomArray(vec(x.x))
3638

3739
struct CustomStyle{N} <: Broadcast.BroadcastStyle where {N} end
38-
CustomStyle(::Val{N}) where N = CustomStyle{N}()
39-
CustomStyle{M}(::Val{N}) where {N,M} = NoIndexStyle{N}()
40-
Base.BroadcastStyle(::Type{<:CustomArray{T,N}}) where {T,N} = CustomStyle{N}()
41-
Broadcast.BroadcastStyle(::CustomStyle{N}, ::Broadcast.DefaultArrayStyle{0}) where {N} = CustomStyle{N}()
42-
Base.similar(bc::Base.Broadcast.Broadcasted{CustomStyle{N}}, ::Type{ElType}) where {N, ElType} = CustomArray(similar(Array{ElType, N}, axes(bc)))
40+
CustomStyle(::Val{N}) where {N} = CustomStyle{N}()
41+
CustomStyle{M}(::Val{N}) where {N, M} = NoIndexStyle{N}()
42+
Base.BroadcastStyle(::Type{<:CustomArray{T, N}}) where {T, N} = CustomStyle{N}()
43+
function Broadcast.BroadcastStyle(
44+
::CustomStyle{N}, ::Broadcast.DefaultArrayStyle{0}) where {N}
45+
CustomStyle{N}()
46+
end
47+
function Base.similar(
48+
bc::Base.Broadcast.Broadcasted{CustomStyle{N}}, ::Type{ElType}) where {N, ElType}
49+
CustomArray(similar(Array{ElType, N}, axes(bc)))
50+
end
4351
Base.@propagate_inbounds Base.Broadcast._broadcast_getindex(x::CustomArray, i) = x.x[i]
4452
Base.Broadcast.extrude(x::CustomArray) = x
4553
Base.Broadcast.broadcastable(x::CustomArray) = x
4654

47-
@inline function Base.copyto!(dest::CustomArray, bc::Base.Broadcast.Broadcasted{<:Union{Base.Broadcast.AbstractArrayStyle,CustomStyle}})
55+
@inline function Base.copyto!(dest::CustomArray,
56+
bc::Base.Broadcast.Broadcasted{<:Union{
57+
Base.Broadcast.AbstractArrayStyle, CustomStyle}})
4858
axes(dest) == axes(bc) || throwdm(axes(dest), axes(bc))
4959
bc′ = Base.Broadcast.preprocess(dest, bc)
5060
dest′ = dest.x
@@ -75,7 +85,7 @@ RecursiveArrayTools.recursivefill!(x::CustomArray, a) = fill!(x, a)
7585

7686
Base.show_vector(io::IO, x::CustomArray) = Base.show_vector(io, x.x)
7787

78-
Base.show(io::IO, x::CustomArray) = (print(io, "CustomArray");show(io, x.x))
88+
Base.show(io::IO, x::CustomArray) = (print(io, "CustomArray"); show(io, x.x))
7989
function Base.show(io::IO, ::MIME"text/plain", x::CustomArray)
8090
println(io, Base.summary(x), ":")
8191
Base.print_array(io, x.x)
@@ -89,9 +99,11 @@ algs = [Tsit5(), BS3(), Vern9(), DP5()]
8999

90100
for alg in algs
91101
function cost(p)
92-
prob = ODEProblem((du, u, p, t) -> (du[1] = p[1]*u[1] + p[2]*u[2]; du[2] = p[2]*u[1]), ca0, tspan, p)
102+
prob = ODEProblem(
103+
(du, u, p, t) -> (du[1] = p[1] * u[1] + p[2] * u[2]; du[2] = p[2] * u[1]),
104+
ca0, tspan, p)
93105
sol = solve(prob, alg; save_everystep = false)
94106
return 1 - norm(sol[end])^2
95107
end
96108
@test_nowarn Zygote.gradient(cost, par)
97-
end
109+
end

test/runtests.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ end
7474
@time @safetestset "ForwardDiff Sparsity Components" include("forwarddiffsensitivity_sparsity_components.jl")
7575
@time @safetestset "Complex No u" include("complex_no_u.jl")
7676
@time @safetestset "Parameter Handling" include("parameter_handling.jl")
77-
@time @safetestset "Quality Assurance" include("aqua.jl")
7877
end
7978
end
8079

@@ -101,6 +100,10 @@ end
101100
end
102101
end
103102

103+
if GROUP == "All" || GROUP == "QA"
104+
@time @safetestset "Quality Assurance" include("aqua.jl")
105+
end
106+
104107
if GROUP == "All" || GROUP == "SDE1"
105108
@testset "SDE 1" begin
106109
@time @safetestset "SDE Adjoint" include("sde_stratonovich.jl")

test/sde_transformation_test.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ prob_strat = SDEProblem{false}(
4545
tspan,
4646
p)
4747
Random.seed!(seed)
48-
sol_strat = solve(prob_strat, RKMil(interpretation = SciMLBase.AlgorithmInterpretation.Stratonovich), adaptive = false,
48+
sol_strat = solve(
49+
prob_strat, RKMil(interpretation = SciMLBase.AlgorithmInterpretation.Stratonovich),
50+
adaptive = false,
4951
dt = 0.0001, save_noise = true)
5052
prob_strat1 = SDEProblem{false}(
5153
SDEFunction((u, p, t) -> transformed_function(u, p, t) .+
@@ -56,7 +58,9 @@ prob_strat1 = SDEProblem{false}(
5658
tspan,
5759
p)
5860
Random.seed!(seed)
59-
sol_strat1 = solve(prob_strat1, RKMil(interpretation = SciMLBase.AlgorithmInterpretation.Stratonovich), adaptive = false,
61+
sol_strat1 = solve(
62+
prob_strat1, RKMil(interpretation = SciMLBase.AlgorithmInterpretation.Stratonovich),
63+
adaptive = false,
6064
dt = 0.0001, save_noise = true)
6165

6266
# Test if we recover Ito solution in Stratonovich sense

0 commit comments

Comments
 (0)