Skip to content

Commit bd9d394

Browse files
kshyattlkdvos
andcommitted
Apply suggestions from code review
Co-authored-by: Lukas Devos <ldevos98@gmail.com>
1 parent 9a07b42 commit bd9d394

1 file changed

Lines changed: 4 additions & 9 deletions

File tree

src/tensors/braidingtensor.jl

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ struct BraidingTensor{T, S, A <: DenseVector{T}} <: AbstractTensorMap{T, S, 2, 2
2828
end
2929
end
3030
function BraidingTensor{T}(V1::S, V2::S, adjoint::Bool = false) where {T, S <: IndexSpace}
31-
TA = similarstoragetype(T)
32-
return BraidingTensor{T, S, TA}(V1, V2, adjoint)
31+
return braidingtensortype(S, T)(V1, V2, adjoint)
3332
end
3433
function BraidingTensor(V1::S, V2::S, adjoint::Bool = false) where {S <: IndexSpace}
3534
T = BraidingStyle(sectortype(S)) isa SymmetricBraiding ? Float64 : ComplexF64
@@ -60,9 +59,8 @@ end
6059

6160
# these are here to make the preprocessing for `@planar` expressions less painful
6261
function braidingtensortype(::Type{S}, ::Type{TorA}) where {S <: IndexSpace, TorA}
63-
T = eltype(TorA)
64-
TA = similarstoragetype(TorA)
65-
return BraidingTensor{T, S, TA}
62+
A = similarstoragetype(TorA)
63+
return BraidingTensor{scalartype(A), S, A}
6664
end
6765
braidingtensortype(V::S, ::Type{TorA}) where {S <: IndexSpace, TorA} = braidingtensortype(S, TorA)
6866
braidingtensortype(V1::S, V2::S, ::Type{TorA}) where {S <: IndexSpace, TorA} = braidingtensortype(S, TorA)
@@ -73,10 +71,7 @@ end
7371
function braidingtensortype(V::HomSpace, ::Type{TorA}) where {TorA}
7472
domain(V) == reverse(codomain(V)) ||
7573
throw(SpaceMismatch("Cannot define a braiding on $V"))
76-
T = eltype(TorA)
77-
S = spacetype(V[2])
78-
TA = similarstoragetype(TorA)
79-
return braidingtensortype(S, TA)
74+
return braidingtensortype(spacetype(V), TorA)
8075
end
8176

8277
storagetype(::Type{BraidingTensor{T, S, A}}) where {T, S, A} = A

0 commit comments

Comments
 (0)