diff --git a/src/tensors/braidingtensor.jl b/src/tensors/braidingtensor.jl index d9dbba56c..3ff8a9abf 100644 --- a/src/tensors/braidingtensor.jl +++ b/src/tensors/braidingtensor.jl @@ -99,8 +99,8 @@ function _braiding_factor(f₁, f₂, inv::Bool = false) return r end -@inline function Base.getindex( - b::BraidingTensor, f₁::FusionTree{I, 2}, f₂::FusionTree{I, 2} +@inline function subblock( + b::BraidingTensor, (f₁, f₂)::Tuple{FusionTree{I, 2}, FusionTree{I, 2}} ) where {I <: Sector} I == sectortype(b) || throw(SectorMismatch()) c = f₁.coupled @@ -126,10 +126,6 @@ end end return data end -@inline function Base.getindex(b::BraidingTensor, ::Nothing, ::Nothing) - sectortype(b) === Trivial || throw(SectorMismatch()) - return getindex(b) -end # efficient copy constructor Base.copy(b::BraidingTensor) = b @@ -169,7 +165,7 @@ function block(b::BraidingTensor, s::Sector) for ((f₁, f₂), (sz, str, off)) in pairs(subblockstructure(space(b))) (f₁.coupled == f₂.coupled == s) || continue - r = _braiding_factor(f₁, f₂) + r = _braiding_factor(f₁, f₂, b.adjoint) isnothing(r) && continue # change offset to account for single block subblock = StridedView(data, sz, str, off - base_offset) diff --git a/test/tensors/planar.jl b/test/tensors/planar.jl index 31b8c143e..780fc821d 100644 --- a/test/tensors/planar.jl +++ b/test/tensors/planar.jl @@ -40,6 +40,16 @@ using .TestSetup for (f1, f2) in fusiontrees(t1) @test t1[f1, f2] ≈ t3[f1, f2] end + + t5 = @inferred TensorMap(t2') + t6 = braid(id(storagetype(t2), domain(t2')), ((2, 1), (3, 4)), (4, 3, 2, 1)) + @test t5 ≈ t6 + for (c, b) in blocks(t1') + @test block(t1', c) ≈ b ≈ block(t5, c) + end + for (f1, f2) in fusiontrees(t1') + @test t1'[f1, f2] ≈ t5[f1, f2] + end end end