Skip to content

Commit d161568

Browse files
committed
apply some suggested changes
1 parent 24e0f4b commit d161568

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

src/bimodulesector.jl

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -162,15 +162,15 @@ function Base.one(a::BimoduleSector)
162162
end
163163

164164
function TensorKitSectors.leftone(a::BimoduleSector)
165-
return A4Object(a.i, a.i, _get_dual_cache(typeof(a))[1][a.i])
165+
return typeof(a)(a.i, a.i, _get_dual_cache(typeof(a))[1][a.i])
166166
end
167167

168168
function TensorKitSectors.rightone(a::BimoduleSector)
169-
return A4Object(a.j, a.j, _get_dual_cache(typeof(a))[1][a.j])
169+
return typeof(a)(a.j, a.j, _get_dual_cache(typeof(a))[1][a.j])
170170
end
171171

172172
function Base.conj(a::BimoduleSector)
173-
return A4Object(a.j, a.i, _get_dual_cache(typeof(a))[2][a.i, a.j][a.label])
173+
return typeof(a)(a.j, a.i, _get_dual_cache(typeof(a))[2][a.i, a.j][a.label])
174174
end
175175

176176
function extract_Fsymbol(::Type{A4Object})
@@ -282,22 +282,18 @@ function Base.oneunit(S::GradedSpace{<:BimoduleSector})
282282
first(sectors(S)).i == first(sectors(S)).j ||
283283
throw(ArgumentError("sectors of $S are non-diagonal"))
284284
sector = one(first(sectors(S)))
285-
return ℂ[A4Object](sector => 1)
285+
return spacetype(S)(sector => 1)
286286
end
287287

288288
function Base.oneunit(S::SumSpace{<:GradedSpace{<:BimoduleSector}})
289-
allequal(a.i for a in sectors(S)) && allequal(a.j for a in sectors(S)) ||
290-
throw(ArgumentError("sectors of $S are not all equal"))
291-
first(sectors(S)).i == first(sectors(S)).j ||
292-
throw(ArgumentError("sectors of $S are non-diagonal"))
293-
sector = one(first(sectors(S)))
294-
return SumSpace(ℂ[A4Object](sector => 1))
289+
@assert !isempty(S) "Cannot determine type of empty space"
290+
return SumSpace(oneunit(first(S.spaces)))
295291
end
296292

297293
# maybe from the homspace
298294
function TensorKit.insertrightunit(P::ProductSpace{V,N}, ::Val{i}=Val(length(P));
299295
conj::Bool=false,
300-
dual::Bool=false) where {i,V<:GradedSpace{<:I},N} where {I<:BimoduleSector}
296+
dual::Bool=false) where {i,V<:GradedSpace{I},N} where {I<:BimoduleSector}
301297
#possible change to rightone of correct space for N = 0
302298
u = N > 0 ? oneunit(P[1]) : error("no unit object in $P")
303299
if dual
@@ -311,7 +307,7 @@ end
311307

312308
function TensorKit.insertleftunit(P::ProductSpace{V,N}, ::Val{i}=Val(length(P) + 1);
313309
conj::Bool=false,
314-
dual::Bool=false) where {i,V<:GradedSpace{<:I},N} where {I<:BimoduleSector}
310+
dual::Bool=false) where {i,V<:GradedSpace{I},N} where {I<:BimoduleSector}
315311
u = N > 0 ? oneunit(P[1]) : error("no unit object in $P")
316312
if dual
317313
u = TensorKit.dual(u)

0 commit comments

Comments
 (0)