Skip to content

Commit 60bb6a5

Browse files
fix tests and most depwarns
1 parent a2bd6ce commit 60bb6a5

File tree

5 files changed

+51
-41
lines changed

5 files changed

+51
-41
lines changed

src/DiffEqDevTools.jl

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@ import DiffEqBase: AbstractODEProblem, AbstractDDEProblem,
1717
ODERKTableau, AbstractTimeseriesSolution, ExplicitRKTableau,
1818
ImplicitRKTableau
1919

20+
import LinearAlgebra: norm, I
2021

2122
const TIMESERIES_ERRORS = Set([:l2,:l∞,:L2,:L∞])
2223
const DENSE_ERRORS = Set([:L2,:L∞])
2324
const WEAK_TIMESERIES_ERRORS = Set([:weak_l2,:weak_l∞])
2425
const WEAK_DENSE_ERRORS = Set([:weak_L2,:weak_L∞])
25-
const WEAK_ERRORS = union(Set([:weak_final]),WEAK_TIMESERIES_ERRORS,WEAK_DENSE_ERRORS)
26-
26+
const WEAK_ERRORS = union(Set([:weak_final]),
27+
WEAK_TIMESERIES_ERRORS,WEAK_DENSE_ERRORS)
2728

2829
parameterless_type(T::Type) = Base.typename(T).wrapper
2930
parameterless_type(x) = parameterless_type(typeof(x))
@@ -53,32 +54,48 @@ export constructEuler, constructKutta3, constructRK4, constructRK438Rule,
5354
constructLobattoIIIA4, constructLobattoIIIB2, constructLobattoIIIB4,
5455
constructLobattoIIIC2, constructLobattoIIIC4, constructLobattoIIICStar2,
5556
constructLobattoIIICStar4, constructLobattoIIID2, constructLobattoIIID4,
56-
constructRadauIA3, constructRadauIA5, constructRadauIIA3, constructRadauIIA5,
57+
constructRadauIA3, constructRadauIA5,
58+
constructRadauIIA3, constructRadauIIA5,
5759
constructRalston, constructHeun, constructRKF5, constructBogakiShampine3,
5860
constructCashKarp, constructRKF8, constructDormandPrince8,
5961
constructMSRI1,constructFeagin10, constructFeagin12, constructFeagin14,
6062
constructDormandPrince8_64bit, constructRKF5, constructRungeFirst5,
61-
constructCassity5, constructLawson5, constructLutherKonen5, constructLutherKonen52,
62-
constructLutherKonen53, constructPapakostasPapaGeorgiou5, constructPapakostasPapaGeorgiou52,
63+
constructCassity5, constructLawson5,
64+
constructLutherKonen5, constructLutherKonen52,
65+
constructLutherKonen53, constructPapakostasPapaGeorgiou5,
66+
constructPapakostasPapaGeorgiou52,
6367
constructTsitouras5, constructBogakiShampine5, constructSharpSmart5,
64-
constructButcher6, constructButcher7, constructDverk, constructClassicVerner6,
65-
constructClassicVerner7, constructClassicVerner8, constructClassicVerner92,
66-
constructVernerRobust7, constructEnrightVerner7, constructTanakaYamashitaStable7,
67-
constructTanakaYamashitaEfficient7, constructSharpSmart7, constructSharpVerner7,
68-
constructVernerEfficient7, constructCooperVerner8, constructCooperVerner82,
68+
constructButcher6, constructButcher7,
69+
constructDverk, constructClassicVerner6,
70+
constructClassicVerner7, constructClassicVerner8,
71+
constructClassicVerner92,
72+
constructVernerRobust7, constructEnrightVerner7,
73+
constructTanakaYamashitaStable7,
74+
constructTanakaYamashitaEfficient7, constructSharpSmart7,
75+
constructSharpVerner7,
76+
constructVernerEfficient7, constructCooperVerner8,
77+
constructCooperVerner82,
6978
constructTsitourasPapakostas8, constructdverk78, constructEnrightVerner8,
7079
constructCurtis8, constructVernerRobust9, constructVernerEfficient9,
71-
constructSharp9, constructTsitouras9, constructTsitouras92,constructFeagin14Tableau,
72-
constructFeagin12Tableau, constructOno12, constructCurtis10, constructOno10, constructFeagin10Tableau,
73-
constructCurtis10, constructBaker10, constructHairer10, constructButcher63,
74-
constructButcher6, constructButcher62, constructVerner6, constructDormandPrince6,
75-
constructSharpVerner6, constructVerner9162, constructVerner916, constructVernerRobust6,
80+
constructSharp9, constructTsitouras9,
81+
constructTsitouras92,constructFeagin14Tableau,
82+
constructFeagin12Tableau, constructOno12, constructCurtis10,
83+
constructOno10, constructFeagin10Tableau,
84+
constructCurtis10, constructBaker10,
85+
constructHairer10, constructButcher63,
86+
constructButcher6, constructButcher62,
87+
constructVerner6, constructDormandPrince6,
88+
constructSharpVerner6, constructVerner9162,
89+
constructVerner916, constructVernerRobust6,
7690
constructVernerEfficient6, constructPapakostas6, constructLawson6,
7791
constructTsitourasPapakostas6, constructDormandLockyerMcCorriganPrince6,
78-
constructTanakaKasugaYamashitaYazaki6D, constructTanakaKasugaYamashitaYazaki6C,
79-
constructTanakaKasugaYamashitaYazaki6B, constructTanakaKasugaYamashitaYazaki6A,
92+
constructTanakaKasugaYamashitaYazaki6D,
93+
constructTanakaKasugaYamashitaYazaki6C,
94+
constructTanakaKasugaYamashitaYazaki6B,
95+
constructTanakaKasugaYamashitaYazaki6A,
8096
constructMikkawyEisa, constructChummund6, constructChummund62,
81-
constructHuta62, constructHuta6, constructRKF4, constructVerner7, constructVerner8,
97+
constructHuta62, constructHuta6, constructRKF4,
98+
constructVerner7, constructVerner8,
8299
constructVerner9, constructVerner6, constructSSPRK22, constructSSPRK33,
83100
constructSSPRK43, constructSSPRK104
84101

src/benchmark.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ function WorkPrecisionSet(prob::Union{AbstractODEProblem,AbstractDDEProblem,
231231
end
232232

233233
@def error_calculation begin
234-
if !has_analytic(prob.f)
234+
if !DiffEqBase.has_analytic(prob.f)
235235
t = prob.tspan[1]:test_dt:prob.tspan[2]
236236
brownian_values = cumsum([[zeros(size(prob.u0))];[sqrt(test_dt)*randn(size(prob.u0)) for i in 1:length(t)-1]])
237237
brownian_values2 = cumsum([[zeros(size(prob.u0))];[sqrt(test_dt)*randn(size(prob.u0)) for i in 1:length(t)-1]])
@@ -275,7 +275,7 @@ end
275275
timeseries_errors=timeseries_errors,
276276
dense_errors = dense_errors)
277277
end
278-
has_analytic(prob.f) ? err_sol = sol : err_sol = appxtrue(sol,true_sol)
278+
DiffEqBase.has_analytic(prob.f) ? err_sol = sol : err_sol = appxtrue(sol,true_sol)
279279
tmp_solutions[i,j,k] = err_sol
280280
end
281281
end
@@ -285,13 +285,13 @@ function WorkPrecisionSet(prob::AbstractRODEProblem,abstols,reltols,setups,test_
285285
print_names=false,names=nothing,appxsol_setup=nothing,
286286
error_estimate=:final,parallel_type = :none,kwargs...)
287287

288-
timeseries_errors = has_analytic(prob.f) && error_estimate TIMESERIES_ERRORS
288+
timeseries_errors = DiffEqBase.has_analytic(prob.f) && error_estimate TIMESERIES_ERRORS
289289
weak_timeseries_errors = error_estimate WEAK_TIMESERIES_ERRORS
290290
weak_dense_errors = error_estimate WEAK_DENSE_ERRORS
291-
dense_errors = has_analytic(prob.f) && error_estimate DENSE_ERRORS
291+
dense_errors = DiffEqBase.has_analytic(prob.f) && error_estimate DENSE_ERRORS
292292
N = length(setups); M = length(abstols)
293-
times = Array{Float64}(M,N)
294-
tmp_solutions = Array{Any}(numruns_error,M,N)
293+
times = Array{Float64}(undef,M,N)
294+
tmp_solutions = Array{Any}(undef,numruns_error,M,N)
295295
if names == nothing
296296
names = [string(parameterless_type(setups[i][:alg])) for i=1:length(setups)]
297297
end
@@ -310,7 +310,7 @@ function WorkPrecisionSet(prob::AbstractRODEProblem,abstols,reltols,setups,test_
310310
analytical_solution_ends = [tmp_solutions[i,1,1].u_analytic[end] for i in 1:numruns_error]
311311
sample_error = 1.96std(norm.(analytical_solution_ends))/sqrt(numruns_error)
312312
_solutions_k = [[MonteCarloSolution(tmp_solutions[:,j,k],0.0,true) for j in 1:M] for k in 1:N]
313-
solutions = [[calculate_monte_errors(sim;weak_timeseries_errors=weak_timeseries_errors,weak_dense_errors=weak_dense_errors) for sim in sol_k] for sol_k in _solutions_k]
313+
solutions = [[DiffEqBase.calculate_monte_errors(sim;weak_timeseries_errors=weak_timeseries_errors,weak_dense_errors=weak_dense_errors) for sim in sol_k] for sol_k in _solutions_k]
314314
if error_estimate WEAK_ERRORS
315315
errors = [[solutions[j][i].weak_errors[error_estimate] for i in 1:M] for j in 1:N]
316316
else
@@ -364,7 +364,7 @@ function WorkPrecisionSet(prob::AbstractRODEProblem,abstols,reltols,setups,test_
364364
end
365365

366366
@def sample_errors begin
367-
if !has_analytic(prob.f)
367+
if !DiffEqBase.has_analytic(prob.f)
368368
true_sol = solve(prob,appxsol_setup[:alg];kwargs...,appxsol_setup...,
369369
save_everystep=false)
370370
analytical_solution_ends[i] = norm(true_sol.u[end])

src/convergence.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ function analyticless_test_convergence(dts::AbstractArray,
6262
timeseries_errors=save_everystep,adaptive=false,
6363
weak_timeseries_errors=false,weak_dense_errors=false,kwargs...)
6464
_solutions = []
65-
tmp_solutions = Array{Any}(numMonte,length(dts))
65+
tmp_solutions = Array{Any}(undef,numMonte,length(dts))
6666
@progress for j in 1:numMonte
6767
t = prob.tspan[1]:test_dt:prob.tspan[2]
6868
brownian_values = cumsum([[zeros(size(prob.u0))];[sqrt(test_dt)*randn(size(prob.u0)) for i in 1:length(t)-1]])
@@ -136,5 +136,6 @@ Base.length(sim::ConvergenceSimulation) = sim.N
136136
Base.endof( sim::ConvergenceSimulation) = length(sim)
137137
Base.getindex(sim::ConvergenceSimulation,i::Int) = sim.solutions[i]
138138
Base.getindex(sim::ConvergenceSimulation,i::Int,I::Int...) = sim.solutions[i][I]
139-
139+
Base.lastindex(sim::ConvergenceSimulation) = lastindex(sim.solutions)
140+
Base.firstindex(sim::ConvergenceSimulation) = firstindex(sim.solutions)
140141
Base.length(sim::ConvergenceSetup) = sim.probs

test/analyticless_stochastic_wp.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
using StochasticDiffEq, DiffEqDevTools, DiffEqProblemLibrary, Test
2+
using DiffEqProblemLibrary.SDEProblemLibrary: importsdeproblems; importsdeproblems()
3+
import DiffEqProblemLibrary.SDEProblemLibrary: prob_sde_additivesystem
24

35
prob = prob_sde_additivesystem
4-
prob = SDEProblem(prob.f,prob.g,prob.u0,(0.0,1.0))
6+
prob = SDEProblem(prob.f,prob.g,prob.u0,(0.0,1.0),prob.p)
57

68
reltols = 1.0./10.0.^(1:5)
79
abstols = reltols#[0.0 for i in eachindex(reltols)]
@@ -22,7 +24,7 @@ se = get_sample_errors(prob,numruns=[5;10;25;50])
2224

2325
println("Now weak error")
2426

25-
prob2 = SDEProblem((du,u,p,t)->prob.f(du,u,p,t),prob.g,prob.u0,(0.0,0.1))
27+
prob2 = SDEProblem((du,u,p,t)->prob.f(du,u,p,t),prob.g,prob.u0,(0.0,0.1),prob.p)
2628
test_dt = 1/10^5
2729
appxsol_setup = Dict(:alg=>SRIW1(),:abstol=>1e-5,:reltol=>1e-5)
2830
wp = WorkPrecisionSet(prob2,abstols,reltols,setups,test_dt;

test/benchmark_tests.jl

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,7 @@ wp_set[end]
6565
@test (minimum(diff(wp_set[2].errors).==0)) # The errors for a fixed timestep method should be constant
6666

6767

68-
# 2D Linear ODE
69-
function f_2dlin(du,u,p,t)
70-
for i in 1:length(u)
71-
du[i] = 1.01*u[i]
72-
end
73-
end
74-
function (::typeof(f_2dlin))(::Type{Val{:analytic}},u₀,p,t)
75-
u₀*exp(1.01*t)
76-
end
77-
tspan = (0.0,10.0)
78-
prob = ODEProblem(f_2dlin,rand(100,100),tspan)
68+
prob = prob_ode_2Dlinear
7969

8070
abstols = 1 ./10 .^(3:7)
8171
reltols = 1 ./10 .^(0:4)

0 commit comments

Comments
 (0)