Skip to content

Commit 7b59f34

Browse files
committed
slight refactor of tests
1 parent 4d98d75 commit 7b59f34

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

test/test_factorizations.jl

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,15 @@ end
119119

120120
function test_svd(a, (U, S, Vᴴ); full=false)
121121
# Check that the SVD is correct
122-
(U * S * Vᴴ a) || return false
123-
(U' * U LinearAlgebra.I) || return false
124-
(Vᴴ * Vᴴ' LinearAlgebra.I) || return false
125-
full || return true
122+
@test (U * S * Vᴴ a)
123+
@test (U' * U LinearAlgebra.I)
124+
@test (Vᴴ * Vᴴ' LinearAlgebra.I)
125+
full || return nothing
126126

127127
# Check factors are unitary
128-
(U * U' LinearAlgebra.I) || return false
129-
(Vᴴ' * Vᴴ LinearAlgebra.I) || return false
130-
return true
128+
@test (U * U' LinearAlgebra.I)
129+
@test (Vᴴ' * Vᴴ LinearAlgebra.I)
130+
return nothing
131131
end
132132

133133
blockszs = (
@@ -143,7 +143,7 @@ test_params = Iterators.product(blockszs, eltypes)
143143

144144
# test empty matrix
145145
usv_empty = svd_compact(a)
146-
@test test_svd(a, usv_empty)
146+
test_svd(a, usv_empty)
147147

148148
# test blockdiagonal
149149
rng = StableRNG(123)
@@ -152,21 +152,21 @@ test_params = Iterators.product(blockszs, eltypes)
152152
a[Block(I.I...)] = rand(rng, T, size(blocks(a)[i]))
153153
end
154154
usv = svd_compact(a)
155-
@test test_svd(a, usv)
155+
test_svd(a, usv)
156156

157157
rng = StableRNG(123)
158158
perm = Random.randperm(rng, length(m))
159159
b = a[Block.(perm), Block.(1:length(n))]
160160
usv = svd_compact(b)
161-
@test test_svd(b, usv)
161+
test_svd(b, usv)
162162

163163
# test permuted blockdiagonal with missing row/col
164164
rng = StableRNG(123)
165165
I_removed = rand(rng, eachblockstoredindex(b))
166166
c = copy(b)
167167
delete!(blocks(c).storage, CartesianIndex(Int.(Tuple(I_removed))))
168168
usv = svd_compact(c)
169-
@test test_svd(c, usv)
169+
test_svd(c, usv)
170170
end
171171

172172
# svd_full!
@@ -176,7 +176,7 @@ end
176176

177177
# test empty matrix
178178
usv_empty = svd_full(a)
179-
@test test_svd(a, usv_empty; full=true)
179+
test_svd(a, usv_empty; full=true)
180180

181181
# test blockdiagonal
182182
rng = StableRNG(123)
@@ -185,21 +185,21 @@ end
185185
a[Block(I.I...)] = rand(rng, T, size(blocks(a)[i]))
186186
end
187187
usv = svd_full(a)
188-
@test test_svd(a, usv; full=true)
188+
test_svd(a, usv; full=true)
189189

190190
rng = StableRNG(123)
191191
perm = Random.randperm(rng, length(m))
192192
b = a[Block.(perm), Block.(1:length(n))]
193193
usv = svd_full(b)
194-
@test test_svd(b, usv; full=true)
194+
test_svd(b, usv; full=true)
195195

196196
# test permuted blockdiagonal with missing row/col
197197
rng = StableRNG(123)
198198
I_removed = rand(rng, eachblockstoredindex(b))
199199
c = copy(b)
200200
delete!(blocks(c).storage, CartesianIndex(Int.(Tuple(I_removed))))
201201
usv = svd_full(c)
202-
@test test_svd(c, usv; full=true)
202+
test_svd(c, usv; full=true)
203203
end
204204

205205
# svd_trunc!

0 commit comments

Comments
 (0)