Skip to content

Commit b64ca37

Browse files
committed
assert spaces are suitable for factorization tests + deal with float dim
1 parent 2ba0306 commit b64ca37

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

test/tensors/factorizations.jl

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ for V in spacelist
3333
@timedtestset "Factorizations with symmetry: $Istr" verbose = true begin
3434
V1, V2, V3, V4, V5 = V
3535
W = V1 V2
36+
@assert !isempty(blocksectors(W))
37+
@assert !isempty(intersect(blocksectors(V4), blocksectors(W)))
3638

3739
@testset "QR decomposition" begin
3840
for T in eltypes,
@@ -236,13 +238,15 @@ for V in spacelist
236238
@test isisometry(U)
237239
@test isisometry(Vᴴ; side = :right)
238240

239-
#FIXME: dimension of S is a float, might be a real issue if it's a decimal
240-
trunc = truncrank(dim(domain(S)) ÷ 2)
241+
# dimension of S is a float for IsingBimodule
242+
nvals = dim(domain(S)) ÷ 2
243+
eltype(nvals) <: AbstractFloat && (nvals = Int(nvals))
244+
trunc = truncrank(nvals)
241245
U1, S1, Vᴴ1 = @constinferred svd_trunc(t; trunc)
242246
@test t * Vᴴ1' U1 * S1
243247
@test isisometry(U1)
244248
@test isisometry(Vᴴ1; side = :right)
245-
@test dim(domain(S1)) <= trunc.howmany
249+
@test dim(domain(S1)) <= nvals
246250

247251
λ = minimum(minimum, values(LinearAlgebra.diag(S1)))
248252
trunc = trunctol(; atol = λ - 10eps(λ))
@@ -269,13 +273,13 @@ for V in spacelist
269273
@test isisometry(Vᴴ4; side = :right)
270274
@test norm(t - U4 * S4 * Vᴴ4) <= 0.5
271275

272-
trunc = truncrank(dim(domain(S)) ÷ 2) & trunctol(; atol = λ - 10eps(λ))
276+
trunc = truncrank(nvals) & trunctol(; atol = λ - 10eps(λ))
273277
U5, S5, Vᴴ5 = @constinferred svd_trunc(t; trunc)
274278
@test t * Vᴴ5' U5 * S5
275279
@test isisometry(U5)
276280
@test isisometry(Vᴴ5; side = :right)
277281
@test minimum(minimum, values(LinearAlgebra.diag(S5))) >= λ
278-
@test dim(domain(S5)) dim(domain(S)) ÷ 2
282+
@test dim(domain(S5)) nvals
279283
end
280284
end
281285

@@ -299,9 +303,11 @@ for V in spacelist
299303
@test @constinferred isposdef(vdv)
300304
t isa DiagonalTensorMap || @test !isposdef(t) # unlikely for non-hermitian map
301305

302-
d, v = @constinferred eig_trunc(t; trunc = truncrank(dim(domain(t)) ÷ 2))
306+
nvals = dim(domain(t)) ÷ 2
307+
eltype(nvals) <: AbstractFloat && (nvals = Int(nvals))
308+
d, v = @constinferred eig_trunc(t; trunc = truncrank(nvals))
303309
@test t * v v * d
304-
@test dim(domain(d)) dim(domain(t)) ÷ 2
310+
@test dim(domain(d)) nvals
305311

306312
t2 = (t + t')
307313
D, V = eigen(t2)
@@ -330,9 +336,9 @@ for V in spacelist
330336
@test isposdef(t - λ * one(t) + 0.1 * one(t))
331337
@test !isposdef(t - λ * one(t) - 0.1 * one(t))
332338

333-
d, v = @constinferred eigh_trunc(t; trunc = truncrank(dim(domain(t)) ÷ 2))
339+
d, v = @constinferred eigh_trunc(t; trunc = truncrank(nvals))
334340
@test t * v v * d
335-
@test dim(domain(d)) dim(domain(t)) ÷ 2
341+
@test dim(domain(d)) nvals
336342
end
337343
end
338344

0 commit comments

Comments
 (0)