Skip to content

Commit

Permalink
Fix the failing github action tests (#297)
Browse files Browse the repository at this point in the history
* Dummy change to get a PR going and trigger the github actions

* Remove many deprecation warnings from the tests

* Update the docs such that we don't recommend indexing with `sol[t]`

* Fix a bug in the classic solver init

* Fix another overlooked old array indexing
  • Loading branch information
nathanaelbosch authored Feb 4, 2024
1 parent fe97a39 commit 8ef0351
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 35 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
[![Coverage](https://codecov.io/gh/nathanaelbosch/ProbNumDiffEq.jl/branch/main/graph/badge.svg?token=eufIemCGXn)](https://codecov.io/gh/nathanaelbosch/ProbNumDiffEq.jl)
[![Benchmarks](http://img.shields.io/badge/benchmarks-docs-blueviolet.svg)](https://nathanaelbosch.github.io/ProbNumDiffEq.jl/dev/benchmarks/multi-language-wrappers/)

<!-- [![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle) -->
<!-- [![ColPrac: Contributor's Guide on Collaborative Practices for Community Packages](https://img.shields.io/badge/ColPrac-Contributor's%20Guide-blueviolet)](https://github.com/SciML/ColPrac) -->
![Banner](./examples/banner.svg?raw=true)

__ProbNumDiffEq.jl__ provides _probabilistic numerical_ ODE solvers to the
Expand Down
12 changes: 3 additions & 9 deletions docs/src/tutorials/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,18 +128,12 @@ plot!(sol.t, zero(errors), ribbon=3error_estimates, label="error estimate",

The solution object returned by ProbNumDiffEq.jl mostly behaves just like any other `ODESolution` in DifferentialEquations.jl --
with some added uncertainties and related functionality on top.
The `ProbabilisticODESolution` can be indexed
The `ProbabilisticODESolution` can be indexed with

```@repl 1
sol[1]
sol[end]
```

and has fields `sol.t` and `sol.u` which store the time points and mean estimates:

```@repl 1
sol.t[end]
sol.u[1]
sol.u[end]
sol.t[end]
```


Expand Down
2 changes: 1 addition & 1 deletion src/initialization/classicsolverinit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function initial_update!(integ, cache, ::ClassicSolverInit)
is_secondorder = integ.f isa DynamicalODEFunction
_u = is_secondorder ? view(u.x[2], :) : view(u, :)
init_condition_on!(x, Proj(0), _u, cache)
is_secondorder ? u.x[1] : f(du, u, p, t)
is_secondorder ? f.f1(du, u.x[1], u.x[2], p, t) : f(du, u, p, t)
integ.stats.nf += 1
init_condition_on!(x, Proj(1), view(du, :), cache)

Expand Down
4 changes: 2 additions & 2 deletions src/perform_step.jl
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ function compute_scaled_error_estimate!(integ, cache)
DiffEqBase.calculate_residuals!(
err_tmp,
err_est_unscaled,
integ.u[1, :],
integ.uprev[1, :],
integ.u.x[1],
integ.uprev.x[1],
integ.opts.abstol,
integ.opts.reltol,
integ.opts.internalnorm,
Expand Down
6 changes: 3 additions & 3 deletions test/callbacks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ end
@test_nowarn solve(prob, EK1(order=3), callback=ManifoldUpdate(E))
sol2 = solve(prob, EK1(order=3), callback=ManifoldUpdate(E))

@test E(sol1[end]) .^ 2 > E(sol2[end]) .^ 2
@test E(sol1.u[end]) .^ 2 > E(sol2.u[end]) .^ 2

err1 = sol1[end] .- appxsol[end]
err2 = sol2[end] .- appxsol[end]
err1 = sol1.u[end] .- appxsol.u[end]
err2 = sol2.u[end] .- appxsol.u[end]
@test all(err1 .^ 2 > err2 .^ 2)
end
8 changes: 4 additions & 4 deletions test/exponential_integrators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ using Test
solexp = solve(prob, ExpEK(L=p, order=3))
solros = solve(prob, RosenbrockExpEK(order=3))

err0 = norm(uend - sol0[end])
err0 = norm(uend - sol0.u[end])
@test err0 < 1e-7
err1 = norm(uend - sol1[end])
err1 = norm(uend - sol1.u[end])
@test err1 < 1e-9
errexp = norm(uend - solexp[end])
errexp = norm(uend - solexp.u[end])
@test errexp < 1e-10
errros = norm(uend - solros[end])
errros = norm(uend - solros.u[end])
@test errros < 1e-13

@test errros < errexp < err1 < err0
Expand Down
10 changes: 5 additions & 5 deletions test/ioup.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ prob = ODEProblem(f, u0, tspan)
ref = solve(prob, Vern9(), abstol=1e-9, reltol=1e-9);

sol_iwp = solve(prob, EK1());
err_iwp = norm(ref[end] - sol_iwp[end])
err_iwp = norm(ref.u[end] - sol_iwp.u[end])
@test err_iwp < 1e-5

A_noisy = A + 1e-3 * randn(MersenneTwister(42), 2, 2)

@testset "Adaptive steps" begin
sol_ioup_noisy = solve(prob, EK1(prior=IOUP(3, A_noisy)))
err_ioup_noisy = norm(ref[end] - sol_ioup_noisy[end])
err_ioup_noisy = norm(ref.u[end] - sol_ioup_noisy.u[end])
@test sol_ioup_noisy.stats.nf < sol_iwp.stats.nf
@test err_ioup_noisy < 2e-5

sol_ioup = solve(prob, EK1(prior=IOUP(3, A)))
err_ioup = norm(ref[end] - sol_ioup[end])
err_ioup = norm(ref.u[end] - sol_ioup.u[end])
@test sol_ioup.stats.nf < sol_ioup_noisy.stats.nf
@test err_ioup < 5e-10
end
Expand All @@ -38,7 +38,7 @@ end
prior=IOUP(order, A_noisy),
diffusionmodel=FixedDiffusion(),
), adaptive=false, dt=1e-1)
err = norm(ref[end] - sol[end])
err = norm(ref.u[end] - sol.u[end])
@test err < last_error
last_error = err
end
Expand All @@ -48,7 +48,7 @@ end
@testset "$(typeof(r))" for r in (-α, [-α, -α], [-α 0; 0 -α], -α * I(2))
sol = solve(prob, EK1(prior=IOUP(3, r)))

err = norm(ref[end] - sol[end])
err = norm(ref.u[end] - sol.u[end])
@test err < 6e-6
end
end
12 changes: 6 additions & 6 deletions test/mass_matrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ using Test

@testset "Correct EK1" begin
sol = solve(prob, EK1(order=3))
@test sol[end] ref[end] rtol = 1e-10
@test sol.u[end] ref.u[end] rtol = 1e-10
end

@testset "Kronecker working" begin
Expand All @@ -38,7 +38,7 @@ using Test
s0 = ek0()

ref = solve(prob, RadauIIA5(), abstol=1e-9, reltol=1e-6)
@test s0[end] ref[end] rtol = 1e-7
@test s0.u[end] ref.u[end] rtol = 1e-7

@test s1.pu.Σ[1] isa PSDMatrix{<:Number,<:Matrix}
@test s0.pu.Σ[1] isa PSDMatrix{<:Number,<:ProbNumDiffEq.IsometricKroneckerProduct}
Expand Down Expand Up @@ -68,14 +68,14 @@ end

ref = solve(prob, RadauIIA5())
sol = solve(prob, EK1(order=3))
@test sol[end] ref[end] rtol = 1e-8
@test sol.u[end] ref.u[end] rtol = 1e-8

sol = solve(prob, EK1(order=3, initialization=ForwardDiffInit(3)))
@test sol[end] ref[end] rtol = 1e-8
@test sol.u[end] ref.u[end] rtol = 1e-8

sol = solve(prob, EK1(order=3, initialization=ClassicSolverInit(RadauIIA5())))
@test sol[end] ref[end] rtol = 1e-8
@test sol.u[end] ref.u[end] rtol = 1e-8

sol = solve(prob, EK1(order=3, initialization=SimpleInit()))
@test sol[end] ref[end] rtol = 1e-8
@test sol.u[end] ref.u[end] rtol = 1e-8
end
4 changes: 2 additions & 2 deletions test/smoothing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ end
sol_smooth = solve(prob, EK0(order=q, smooth=true), adaptive=false, dt=dt)

@test sol_nonsmooth.t sol_smooth.t
@test sol_nonsmooth[end] == sol_smooth[end]
@test sol_nonsmooth[end-1] != sol_smooth[end-1]
@test sol_nonsmooth.u[end] == sol_smooth.u[end]
@test sol_nonsmooth.u[end-1] != sol_smooth.u[end-1]

plot(sol_smooth, label="smooth")
plot!(sol_nonsmooth, label="nonsmooth")
Expand Down
2 changes: 1 addition & 1 deletion test/stiff_problem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ using ODEProblemLibrary: prob_ode_vanderpol_stiff
prob = prob_ode_vanderpol_stiff
appxsol = solve(prob, RadauIIA5())
sol = solve(prob, EK1(order=3))
@test appxsol[end] sol[end] rtol = 5e-3
@test appxsol.u[end] sol.u[end] rtol = 5e-3
@test appxsol(0.5) sol(0.5).μ rtol = 5e-3

0 comments on commit 8ef0351

Please sign in to comment.