Skip to content

Commit 995b768

Browse files
committed
encapsule test in let ... end statement
1 parent 10848d6 commit 995b768

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

test/nonlinearsolve_wpdiagram_tests.jl

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,23 @@
22
using NonlinearSolve, DiffEqDevTools, Plots
33

44
# Prepares NonlinearProblem.
5-
f(u, p) = u .* u .- p
6-
u0 = [1.0, 1.0]
7-
p = 2.0
8-
static_prob = NonlinearProblem(f, u0, p)
9-
real_sol = solve(static_prob, NewtonRaphson(), reltol = 1e-15, abstol = 1e-15)
5+
let
6+
f(u, p) = u .* u .- p
7+
u0 = [1.0, 1.0]
8+
p = 2.0
9+
static_prob = NonlinearProblem(f, u0, p)
10+
real_sol = solve(static_prob, NewtonRaphson(), reltol = 1e-15, abstol = 1e-15)
1011

11-
# Sets WP input.
12-
abstols = 1.0 ./ 10.0 .^ (8:12)
13-
reltols = 1.0 ./ 10.0 .^ (8:12)
14-
setups = [Dict(:alg=>NewtonRaphson())
15-
Dict(:alg=>TrustRegion())]
16-
solnames = ["NewtonRaphson";"TrustRegion"]
12+
# Sets WP input.
13+
abstols = 1.0 ./ 10.0 .^ (8:12)
14+
reltols = 1.0 ./ 10.0 .^ (8:12)
15+
setups = [Dict(:alg=>NewtonRaphson())
16+
Dict(:alg=>TrustRegion())]
17+
solnames = ["NewtonRaphson";"TrustRegion"]
1718

18-
# Makes WP-diagram
19-
wp = WorkPrecisionSet(static_prob, abstols, reltols, setups; names=solnames, numruns=100, appxsol=real_sol, error_estimate=:l2)
19+
# Makes WP-diagram
20+
wp = WorkPrecisionSet(static_prob, abstols, reltols, setups; names=solnames, numruns=100, appxsol=real_sol, error_estimate=:l2)
2021

21-
# Checks that all errors are small (they definitely should be).
22-
all(vcat(getfield.(wp.wps, :errors)...) .< 10e-9)
22+
# Checks that all errors are small (they definitely should be).
23+
all(vcat(getfield.(wp.wps, :errors)...) .< 10e-9)
24+
end

0 commit comments

Comments
 (0)