Skip to content

Commit e794d96

Browse files
committed
More stable tests
1 parent 0f10d21 commit e794d96

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

test/Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ KroneckerArrays = "05d0b138-81bc-4ff7-84be-08becefb1ccc"
55
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
66
MatrixAlgebraKit = "6c742aac-3347-4629-af66-fc926824e5e4"
77
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
8+
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
89
Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb"
910
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
1011
TestExtras = "5ed8adda-3752-4e41-b88a-e8b09835ee3a"
@@ -16,6 +17,7 @@ KroneckerArrays = "0.1"
1617
LinearAlgebra = "1.10"
1718
MatrixAlgebraKit = "0.2"
1819
SafeTestsets = "0.1"
20+
StableRNGs = "1.0"
1921
Suppressor = "0.2"
2022
Test = "1.10"
2123
TestExtras = "0.3"

test/test_basics.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using FillArrays: Eye
22
using KroneckerArrays: KroneckerArrays, , ×, diagonal, kron_nd
33
using LinearAlgebra: Diagonal, I, det, eigen, eigvals, lq, pinv, qr, svd, svdvals, tr
4+
using StableRNGs: StableRNG
45
using Test: @test, @test_broken, @test_throws, @testset
56

67
const elts = (Float32, Float64, ComplexF32, ComplexF64)
@@ -98,11 +99,12 @@ end
9899
@test a * a == (a.a * a.a) Eye(2)
99100

100101
# Eye ⊗ A
101-
a = Eye(2) randn(3, 3)
102+
rng = StableRNG(123)
103+
a = Eye(2) randn(rng, 3, 3)
102104
for f in MATRIX_FUNCTIONS
103105
@eval begin
104106
fa = $f($a)
105-
@test collect(fa) $f(collect($a)) rtol = (eps(real(eltype($a))))
107+
@test collect(fa) $f(collect($a)) rtol = (eps(real(eltype($a))))
106108
@test fa.a isa Eye
107109
end
108110
end
@@ -118,11 +120,12 @@ end
118120
@test det(a) det(collect(a))
119121

120122
# A ⊗ Eye
121-
a = randn(3, 3) Eye(2)
123+
rng = StableRNG(123)
124+
a = randn(rng, 3, 3) Eye(2)
122125
for f in MATRIX_FUNCTIONS
123126
@eval begin
124127
fa = $f($a)
125-
@test collect(fa) $f(collect($a)) rtol = (eps(real(eltype($a))))
128+
@test collect(fa) $f(collect($a)) rtol = (eps(real(eltype($a))))
126129
@test fa.b isa Eye
127130
end
128131
end

0 commit comments

Comments
 (0)