Skip to content

Commit 0290c71

Browse files
Make random numbers deterministic for graph matrices tests (#97)
1 parent c834d2c commit 0290c71

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

test/linalg/graphmatrices.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
using ArnoldiMethod
33

44
@testset "Graph matrices" begin
5+
6+
# TODO fixing the random number generator is not ideal, but currently
7+
# the tests here fail a bit too often when running them in ci/cd.
8+
rng = MersenneTwister(1234)
9+
510
function converttest(T::Type, var)
611
@test typeof(T(var)) == T
712
end
@@ -176,13 +181,13 @@ using ArnoldiMethod
176181

177182
n = 10
178183

179-
mat = Float64.(sprand(Bool, n, n, 0.3))
184+
mat = Float64.(sprand(rng, Bool, n, n, 0.3))
180185

181186
test_adjacency(mat)
182187
test_laplacian(mat)
183188
test_accessors(mat, n)
184189

185-
mat = symmetrize(Float64.(sprand(Bool, n, n, 0.3)))
190+
mat = symmetrize(Float64.(sprand(rng, Bool, n, n, 0.3)))
186191
test_arithmetic(mat, n)
187192
test_other(mat, n)
188193
test_symmetry(mat, n)
@@ -212,7 +217,7 @@ using ArnoldiMethod
212217
# Random walk demo
213218
n = 100
214219
p = 16 / n
215-
M = sprand(n, n, p)
220+
M = sprand(rng, n, n, p)
216221
M.nzval[:] .= 1.0
217222
A = CombinatorialAdjacency(M)
218223
sd = stationarydistribution(A; mindim=10)

0 commit comments

Comments
 (0)