Skip to content

Commit b87972c

Browse files
committed
define checkspaces
1 parent d972a21 commit b87972c

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

src/fusiontensor/base_interface.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ end
1919

2020
# tensor addition is a block data_matrix add.
2121
function Base.:+(left::FusionTensor, right::FusionTensor)
22-
axes(left) == axes(right) || throw(ArgumentError("Axes do not match"))
22+
checkspaces(axes(left), axes(right))
2323
return set_data_matrix(left, data_matrix(left) + data_matrix(right))
2424
end
2525

2626
Base.:-(ft::FusionTensor) = set_data_matrix(ft, -data_matrix(ft))
2727

2828
function Base.:-(left::FusionTensor, right::FusionTensor)
29-
axes(left) == axes(right) || throw(ArgumentError("Axes do not match"))
29+
checkspaces(axes(left), axes(right))
3030
return set_data_matrix(left, data_matrix(left) - data_matrix(right))
3131
end
3232

src/fusiontensor/fusiontensoraxes.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ function GradedArrays.sector_type(::Type{FTA}) where {BT,FTA<:FusionTensorAxes{B
110110
return sector_type(type_parameters(type_parameters(BT, 3), 1))
111111
end
112112

113+
function GradedArrays.checkspaces(
114+
::Type{Bool}, left::FusionTensorAxes, right::FusionTensorAxes
115+
)
116+
return left == right
117+
end
118+
113119
# ============================== FusionTensor interface ==================================
114120

115121
codomain(fta::FusionTensorAxes) = fta[Block(1)]

test/test_fusiontensoraxes.jl

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Test: @test, @testset
1+
using Test: @test, @test_throws, @testset
22

33
using TensorProducts:
44
using BlockArrays: Block, blockedrange, blocklength, blocklengths, blocks
@@ -15,7 +15,16 @@ using FusionTensors:
1515
promote_sector_type,
1616
promote_sectors
1717
using GradedArrays:
18-
×, U1, SectorProduct, TrivialSector, SU2, dual, gradedrange, sector_type, space_isequal
18+
×,
19+
U1,
20+
SectorProduct,
21+
TrivialSector,
22+
SU2,
23+
checkspaces,
24+
dual,
25+
gradedrange,
26+
sector_type,
27+
space_isequal
1928

2029
@testset "misc FusionTensors.jl" begin
2130
g1 = gradedrange([U1(0) => 1])
@@ -83,6 +92,10 @@ end
8392
@test fta != FusionTensorAxes(tuplemortar(((g2, g2, g2b), (g2b,))))
8493

8594
@test fta == FusionTensorAxes((g2, g2), (g2b, g2b))
95+
@test checkspaces(fta, fta)
96+
@test_throws ArgumentError checkspaces(
97+
fta, FusionTensorAxes(tuplemortar(((g2, g2), (g2b, g2))))
98+
)
8699
end
87100

88101
@testset "Empty FusionTensorAxes" begin

0 commit comments

Comments
 (0)