Skip to content

Commit bdcc53a

Browse files
committedJan 22, 2025
some more fixes and tests
1 parent 43cb3e3 commit bdcc53a

File tree

4 files changed

+29
-6
lines changed

4 files changed

+29
-6
lines changed
 

‎src/spaces/homspace.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ end
355355
# TODO: is this something we want to cache?
356356
function diagonalblockstructure(W::HomSpace)
357357
((numin(W) == numout(W) == 1) && domain(W) == codomain(W)) ||
358-
throw(ArgumentError("Input space is not diagonal"))
358+
throw(SpaceMismatch("Diagonal only support on V←V with a single space V"))
359359
structure = SectorDict{sectortype(W),UnitRange{Int}}() # range
360360
offset = 0
361361
dom = domain(W)[1]

‎src/tensors/adjoint.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ block(t::AdjointTensorMap, s::Sector) = block(parent(t), s)'
2727

2828
blocks(t::AdjointTensorMap) = BlockIterator(t, blocks(parent(t)))
2929

30-
function blocktype(::Type{TT}) where {T,TT<:AdjointTensorMap{T}}
31-
return Base.promote_op(adjoint, blocktype(T))
30+
function blocktype(::Type{AdjointTensorMap{T,S,N₁,N₂,TT}}) where {T,S,N₁,N₂,TT}
31+
return Base.promote_op(adjoint, blocktype(TT))
3232
end
3333

3434
function Base.iterate(iter::BlockIterator{<:AdjointTensorMap}, state...)

‎test/diagonal.jl

+9
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ diagspacelist = ((ℂ^4)', ℂ[Z2Irrep](0 => 2, 1 => 3),
1414
@test space(t) == (V V)
1515
@test space(t') == (V V)
1616
@test dim(t) == dim(space(t))
17+
# blocks
18+
bs = @constinferred blocks(t)
19+
(c, b1), state = @constinferred Nothing iterate(bs)
20+
@test c == first(blocksectors(V V))
21+
next = @constinferred Nothing iterate(bs, state)
22+
b2 = @constinferred block(t, first(blocksectors(t)))
23+
@test b1 == b2
24+
@test eltype(bs) === typeof(b1) === TensorKit.blocktype(t)
25+
# basic linear algebra
1726
@test isa(@constinferred(norm(t)), real(T))
1827
@test norm(t)^2 dot(t, t)
1928
α = rand(T)

‎test/tensors.jl

+17-3
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,14 @@ for V in spacelist
9191
@test space(t) == (W one(W))
9292
@test domain(t) == one(W)
9393
@test typeof(t) == TensorMap{T,spacetype(t),5,0,Vector{T}}
94-
bs = @inferred blocks(t)
95-
b = @inferred block(t, first(blocksectors(t)))
96-
@test eltype(bs) === typeof(b) === TensorKit.blocktype(t)
94+
# blocks
95+
bs = @constinferred blocks(t)
96+
(c, b1), state = @constinferred Nothing iterate(bs)
97+
@test c == first(blocksectors(W))
98+
next = @constinferred Nothing iterate(bs, state)
99+
b2 = @constinferred block(t, first(blocksectors(t)))
100+
@test b1 == b2
101+
@test eltype(bs) === typeof(b1) === TensorKit.blocktype(t)
97102
end
98103
end
99104
@timedtestset "Tensor Dict conversion" begin
@@ -146,6 +151,15 @@ for V in spacelist
146151
@test dim(t) == dim(space(t))
147152
@test codomain(t) == codomain(W)
148153
@test domain(t) == domain(W)
154+
# blocks for adjoint
155+
bs = @constinferred blocks(t')
156+
(c, b1), state = @constinferred Nothing iterate(bs)
157+
@test c == first(blocksectors(W'))
158+
next = @constinferred Nothing iterate(bs, state)
159+
b2 = @constinferred block(t', first(blocksectors(t')))
160+
@test b1 == b2
161+
@test eltype(bs) === typeof(b1) === TensorKit.blocktype(t')
162+
# linear algebra
149163
@test isa(@constinferred(norm(t)), real(T))
150164
@test norm(t)^2 dot(t, t)
151165
α = rand(T)

0 commit comments

Comments
 (0)