Skip to content

Commit 83ec485

Browse files
committed
clean up tests
1 parent 4c9b487 commit 83ec485

File tree

1 file changed

+43
-14
lines changed

1 file changed

+43
-14
lines changed

test/runtests.jl

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,21 @@ using Test
1515
prob2 = LinearProblem(A2, b2; u0=x2)
1616
prob3 = LinearProblem(A3, b3; u0=x3)
1717

18-
for alg in (
19-
:LUFactorization,
20-
:QRFactorization,
21-
:SVDFactorization,
22-
23-
# :DefaultLinSolve,
18+
function test_interface(alg, kwargs, prob1, prob2, prob3)
19+
A1 = prob1.A; b1 = prob1.b; x1 = prob1.u0
20+
A2 = prob2.A; b2 = prob2.b; x2 = prob2.u0
21+
A3 = prob3.A; b3 = prob3.b; x3 = prob3.u0
2422

25-
:KrylovJL, :KrylovJL_CG, :KrylovJL_GMRES, :KrylovJL_BICGSTAB,
26-
:KrylovJL_MINRES,
27-
:IterativeSolversJL, :IterativeSolversJL_GMRES,
28-
:IterativeSolversJL_BICGSTAB, :IterativeSolversJL_MINRES
29-
)
3023
@eval begin
31-
y = solve($prob1, $alg())
24+
y = solve($prob1, $alg($kwargs...))
3225
@test $A1 * y $b1 # out of place
3326
@test $A1 * $x1 $b1 # in place
3427

35-
y = $alg()($x2, $A2, $b2) # alg is callable
28+
y = $alg($kwargs...)($x2, $A2, $b2) # alg is callable
3629
@test $A2 * y $b2
3730
@test $A2 * $x2 $b2
3831

39-
cache = SciMLBase.init($prob1, $alg()) # initialize cache
32+
cache = SciMLBase.init($prob1, $alg($kwargs...)) # initialize cache
4033
y = cache($x3, $A1, $b1) # cache is callable
4134
@test $A1 * y $b1
4235
@test $A1 * $x3 $b1
@@ -49,6 +42,42 @@ using Test
4942
@test $A2 * y $b3 # same old cache
5043
@test $A2 * $x3 $b3
5144
end
45+
46+
return
47+
end
48+
49+
# Factorizations
50+
kwargs = :()
51+
for alg in (
52+
:LUFactorization,
53+
:QRFactorization,
54+
:SVDFactorization,
55+
)
56+
test_interface(alg, kwargs, prob1, prob2, prob3)
57+
end
58+
59+
# KrylovJL
60+
kwargs = :(verbose=1, abstol=1e-1, reltol=1e-1, maxiters=3, restart=5)
61+
for alg in (
62+
:KrylovJL,
63+
:KrylovJL_CG,
64+
:KrylovJL_GMRES,
65+
:KrylovJL_BICGSTAB,
66+
:KrylovJL_MINRES,
67+
)
68+
test_interface(alg, kwargs, prob1, prob2, prob3)
69+
end
70+
71+
# IterativeSolversJL
72+
kwargs = :(abstol=1e-1, reltol=1e-1, maxiters=3, restart=5)
73+
for alg in (
74+
:IterativeSolversJL,
75+
:IterativeSolversJL_CG,
76+
:IterativeSolversJL_GMRES,
77+
:IterativeSolversJL_BICGSTAB,
78+
:IterativeSolversJL_MINRES,
79+
)
80+
test_interface(alg, kwargs, prob1, prob2, prob3)
5281
end
5382

5483
end

0 commit comments

Comments
 (0)