Skip to content

Commit 0566cba

Browse files
committed
update braiding check
1 parent be0ca23 commit 0566cba

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

src/tensors/braidingtensor.jl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@ struct BraidingTensor{T, S, A <: DenseVector{T}} <: AbstractTensorMap{T, S, 2, 2
1919
V2::S
2020
adjoint::Bool
2121
function BraidingTensor{T, S, A}(V1::S, V2::S, adjoint::Bool = false) where {T, S <: IndexSpace, A <: DenseVector{T}}
22-
for a in sectors(V1), b in sectors(V2), c in (a b)
23-
Nsymbol(a, b, c) == Nsymbol(b, a, c) ||
24-
throw(ArgumentError("Cannot define a braiding between $a and $b"))
25-
end
22+
check_valid_braiding(V1, V1) ||
23+
throw(ArgumentError(lazy"Cannot define a braiding between $V1 and $V2"))
2624
return new{T, S, A}(V1, V2, adjoint)
27-
# partial construction: only construct rowr and colr when needed
2825
end
2926
end
27+
28+
check_valid_braiding(V₁::S, V₂::S) where {S <: ElementarySpace} =
29+
BraidingStyle(sectortype(S)) isa HasBraiding || (isunitspace(V₁) || isunitspace(V₂))
30+
3031
function BraidingTensor{T}(V1::S, V2::S, adjoint::Bool = false) where {T, S <: IndexSpace}
3132
TA = similarstoragetype(T)
3233
return BraidingTensor{T, S, TA}(V1, V2, adjoint)

0 commit comments

Comments
 (0)