Skip to content

Commit 6cc0618

Browse files
committed
fix bad merge conflict choices
1 parent def9a5e commit 6cc0618

File tree

6 files changed

+76
-64
lines changed

6 files changed

+76
-64
lines changed

src/TensorKit.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ export TruncationScheme
3434
export SpaceMismatch, SectorMismatch, IndexError # error types
3535

3636
# general vector space methods
37-
export space, field, dual, dim, reduceddim, dims, fuse, flip, isdual, oplus,
38-
insertleftunitspace, insertrightunitspace, removeunitspace
37+
# Export general vector space methods
38+
export space, field, dual, dim, reduceddim, dims, fuse, flip, isdual
39+
export unitspace, zerospace, oplus, ominus
40+
export insertleftunitspace, insertrightunitspace, removeunitspace
3941

4042
# partial order for vector spaces
4143
export infimum, supremum, isisomorphic, ismonomorphic, isepimorphic

src/spaces/homspace.jl

Lines changed: 46 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ Represents the linear space of morphisms with codomain of type `P1` and domain o
88
Note that HomSpace is not a subtype of VectorSpace, i.e. we restrict the latter to denote
99
certain categories and their objects, and keep HomSpace distinct.
1010
"""
11-
struct HomSpace{S<:ElementarySpace,P1<:CompositeSpace{S},P2<:CompositeSpace{S}}
11+
struct HomSpace{S <: ElementarySpace, P1 <: CompositeSpace{S}, P2 <: CompositeSpace{S}}
1212
codomain::P1
1313
domain::P2
1414
end
1515

16-
function HomSpace(codomain::S, domain::CompositeSpace{S}) where {S<:ElementarySpace}
16+
function HomSpace(codomain::S, domain::CompositeSpace{S}) where {S <: ElementarySpace}
1717
return HomSpace((codomain), domain)
1818
end
19-
function HomSpace(codomain::CompositeSpace{S}, domain::S) where {S<:ElementarySpace}
19+
function HomSpace(codomain::CompositeSpace{S}, domain::S) where {S <: ElementarySpace}
2020
return HomSpace(codomain, (domain))
2121
end
22-
function HomSpace(codomain::S, domain::S) where {S<:ElementarySpace}
22+
function HomSpace(codomain::S, domain::S) where {S <: ElementarySpace}
2323
return HomSpace((codomain), (domain))
2424
end
2525
HomSpace(codomain::VectorSpace) = HomSpace(codomain, zerospace(codomain))
@@ -45,18 +45,20 @@ numout(W::HomSpace) = length(codomain(W))
4545
numin(W::HomSpace) = length(domain(W))
4646
numind(W::HomSpace) = numin(W) + numout(W)
4747

48-
const TensorSpace{S<:ElementarySpace} = Union{S,ProductSpace{S}}
49-
const TensorMapSpace{S<:ElementarySpace,N₁,N₂} = HomSpace{S,ProductSpace{S,N₁},
50-
ProductSpace{S,N₂}}
48+
const TensorSpace{S <: ElementarySpace} = Union{S, ProductSpace{S}}
49+
const TensorMapSpace{S <: ElementarySpace, N₁, N₂} = HomSpace{
50+
S, ProductSpace{S, N₁},
51+
ProductSpace{S, N₂},
52+
}
5153

52-
function Base.getindex(W::TensorMapSpace{<:IndexSpace,N₁,N₂}, i) where {N₁,N₂}
54+
function Base.getindex(W::TensorMapSpace{<:IndexSpace, N₁, N₂}, i) where {N₁, N₂}
5355
return i <= N₁ ? codomain(W)[i] : dual(domain(W)[i - N₁])
5456
end
5557

56-
function (codom::ProductSpace{S}, dom::ProductSpace{S}) where {S<:ElementarySpace}
58+
function (codom::ProductSpace{S}, dom::ProductSpace{S}) where {S <: ElementarySpace}
5759
return HomSpace(codom, dom)
5860
end
59-
function (codom::S, dom::S) where {S<:ElementarySpace}
61+
function (codom::S, dom::S) where {S <: ElementarySpace}
6062
return HomSpace(ProductSpace(codom), ProductSpace(dom))
6163
end
6264
(codom::VectorSpace, dom::VectorSpace) = (promote(codom, dom)...)
@@ -69,7 +71,7 @@ function Base.show(io::IO, W::HomSpace)
6971
print(io, W.codomain)
7072
end
7173
print(io, "")
72-
if length(W.domain) == 1
74+
return if length(W.domain) == 1
7375
print(io, W.domain[1])
7476
else
7577
print(io, W.domain)
@@ -94,7 +96,7 @@ function blocksectors(W::HomSpace)
9496
N₁ = length(codom)
9597
N₂ = length(dom)
9698
I = sectortype(W)
97-
if N₁ == 0 && N₂ == 0
99+
if N₁ == 0 && N₂ == 0
98100
return allunits(I)
99101
elseif N₁ == 0
100102
return filter!(isone, collect(blocksectors(dom))) # module space cannot end in empty space
@@ -130,6 +132,8 @@ function dim(W::HomSpace)
130132
return d
131133
end
132134

135+
dims(W::HomSpace) = (dims(codomain(W))..., dims(domain(W))...)
136+
133137
"""
134138
fusiontrees(W::HomSpace)
135139
@@ -145,7 +149,7 @@ fusiontrees(W::HomSpace) = fusionblockstructure(W).fusiontreelist
145149
Return the `HomSpace` obtained by permuting the indices of the domain and codomain of `W`
146150
according to the permutation `p₁` and `p₂` respectively.
147151
"""
148-
function permute(W::HomSpace{S}, (p₁, p₂)::Index2Tuple{N₁,N₂}) where {S,N₁,N₂}
152+
function permute(W::HomSpace{S}, (p₁, p₂)::Index2Tuple{N₁, N₂}) where {S, N₁, N₂}
149153
p = (p₁..., p₂...)
150154
TupleTools.isperm(p) && length(p) == numind(W) ||
151155
throw(ArgumentError("$((p₁, p₂)) is not a valid permutation for $(W)"))
@@ -158,9 +162,9 @@ end
158162
Return the `HomSpace` obtained by a selection from the domain and codomain of `W` according
159163
to the indices in `p₁` and `p₂` respectively.
160164
"""
161-
function select(W::HomSpace{S}, (p₁, p₂)::Index2Tuple{N₁,N₂}) where {S,N₁,N₂}
162-
cod = ProductSpace{S,N₁}(map(n -> W[n], p₁))
163-
dom = ProductSpace{S,N₂}(map(n -> dual(W[n]), p₂))
165+
function select(W::HomSpace{S}, (p₁, p₂)::Index2Tuple{N₁, N₂}) where {S, N₁, N₂}
166+
cod = ProductSpace{S, N₁}(map(n -> W[n], p₁))
167+
dom = ProductSpace{S, N₂}(map(n -> dual(W[n]), p₂))
164168
return cod dom
165169
end
166170

@@ -201,8 +205,10 @@ More specifically, adds a left monoidal unit or its dual.
201205
See also [`insertrightunitspace`](@ref insertrightunitspace(::HomSpace, ::Val{i}) where {i}),
202206
[`removeunitspace`](@ref removeunitspace(::HomSpace, ::Val{i}) where {i}).
203207
"""
204-
function insertleftunitspace(W::HomSpace, ::Val{i}=Val(numind(W) + 1);
205-
conj::Bool=false, dual::Bool=false) where {i}
208+
function insertleftunitspace(
209+
W::HomSpace, ::Val{i} = Val(numind(W) + 1);
210+
conj::Bool = false, dual::Bool = false
211+
) where {i}
206212
if i numout(W)
207213
return insertleftunitspace(codomain(W), Val(i); conj, dual) domain(W)
208214
else
@@ -220,8 +226,10 @@ More specifically, adds a right monoidal unit or its dual.
220226
See also [`insertleftunitspace`](@ref insertleftunitspace(::HomSpace, ::Val{i}) where {i}),
221227
[`removeunitspace`](@ref removeunitspace(::HomSpace, ::Val{i}) where {i}).
222228
"""
223-
function insertrightunitspace(W::HomSpace, ::Val{i}=Val(numind(W));
224-
conj::Bool=false, dual::Bool=false) where {i}
229+
function insertrightunitspace(
230+
W::HomSpace, ::Val{i} = Val(numind(W));
231+
conj::Bool = false, dual::Bool = false
232+
) where {i}
225233
if i numout(W)
226234
return insertrightunitspace(codomain(W), Val(i); conj, dual) domain(W)
227235
else
@@ -251,14 +259,14 @@ end
251259
#--------------------------------------------------------------------------
252260

253261
# sizes, strides, offset
254-
const StridedStructure{N} = Tuple{NTuple{N,Int},NTuple{N,Int},Int}
262+
const StridedStructure{N} = Tuple{NTuple{N, Int}, NTuple{N, Int}, Int}
255263

256-
struct FusionBlockStructure{I,N,F₁,F₂}
264+
struct FusionBlockStructure{I, N, F₁, F₂}
257265
totaldim::Int
258-
blockstructure::SectorDict{I,Tuple{Tuple{Int,Int},UnitRange{Int}}}
259-
fusiontreelist::Vector{Tuple{F₁,F₂}}
266+
blockstructure::SectorDict{I, Tuple{Tuple{Int, Int}, UnitRange{Int}}}
267+
fusiontreelist::Vector{Tuple{F₁, F₂}}
260268
fusiontreestructure::Vector{StridedStructure{N}}
261-
fusiontreeindices::FusionTreeDict{Tuple{F₁,F₂},Int}
269+
fusiontreeindices::FusionTreeDict{Tuple{F₁, F₂}, Int}
262270
end
263271

264272
function fusionblockstructuretype(W::HomSpace)
@@ -268,7 +276,7 @@ function fusionblockstructuretype(W::HomSpace)
268276
I = sectortype(W)
269277
F₁ = fusiontreetype(I, N₁)
270278
F₂ = fusiontreetype(I, N₂)
271-
return FusionBlockStructure{I,N,F₁,F₂}
279+
return FusionBlockStructure{I, N, F₁, F₂}
272280
end
273281

274282
@cached function fusionblockstructure(W::HomSpace)::fusionblockstructuretype(W)
@@ -281,13 +289,13 @@ end
281289
F₂ = fusiontreetype(I, N₂)
282290

283291
# output structure
284-
blockstructure = SectorDict{I,Tuple{Tuple{Int,Int},UnitRange{Int}}}() # size, range
285-
fusiontreelist = Vector{Tuple{F₁,F₂}}()
286-
fusiontreestructure = Vector{Tuple{NTuple{N₁ + N₂,Int},NTuple{N₁ + N₂,Int},Int}}() # size, strides, offset
292+
blockstructure = SectorDict{I, Tuple{Tuple{Int, Int}, UnitRange{Int}}}() # size, range
293+
fusiontreelist = Vector{Tuple{F₁, F₂}}()
294+
fusiontreestructure = Vector{Tuple{NTuple{N₁ + N₂, Int}, NTuple{N₁ + N₂, Int}, Int}}() # size, strides, offset
287295

288296
# temporary data structures
289297
splittingtrees = Vector{F₁}()
290-
splittingstructure = Vector{Tuple{Int,Int}}()
298+
splittingstructure = Vector{Tuple{Int, Int}}()
291299

292300
# main computational routine
293301
blockoffset = 0
@@ -327,15 +335,17 @@ end
327335
blockstructure[c] = (blocksize, blockrange)
328336
end
329337

330-
fusiontreeindices = sizehint!(FusionTreeDict{Tuple{F₁,F₂},Int}(),
331-
length(fusiontreelist))
338+
fusiontreeindices = sizehint!(
339+
FusionTreeDict{Tuple{F₁, F₂}, Int}(),
340+
length(fusiontreelist)
341+
)
332342
for (i, f₁₂) in enumerate(fusiontreelist)
333343
fusiontreeindices[f₁₂] = i
334344
end
335345
totaldim = blockoffset
336-
structure = FusionBlockStructure(totaldim, blockstructure,
337-
fusiontreelist, fusiontreestructure,
338-
fusiontreeindices)
346+
structure = FusionBlockStructure(
347+
totaldim, blockstructure, fusiontreelist, fusiontreestructure, fusiontreeindices
348+
)
339349
return structure
340350
end
341351

@@ -357,7 +367,7 @@ end
357367
function diagonalblockstructure(W::HomSpace)
358368
((numin(W) == numout(W) == 1) && domain(W) == codomain(W)) ||
359369
throw(SpaceMismatch("Diagonal only support on V←V with a single space V"))
360-
structure = SectorDict{sectortype(W),UnitRange{Int}}() # range
370+
structure = SectorDict{sectortype(W), UnitRange{Int}}() # range
361371
offset = 0
362372
dom = domain(W)[1]
363373
for c in blocksectors(W)

src/spaces/productspace.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ end
234234
Return a tensor product of zero spaces of type `S`, i.e. this is the unit object under the
235235
tensor product operation, such that `V ⊗ one(V) == V`.
236236
"""
237-
#TODO: unit(V::S)?
237+
238238
Base.one(V::VectorSpace) = one(typeof(V))
239239
Base.one(::Type{<:ProductSpace{S}}) where {S <: ElementarySpace} = ProductSpace{S, 0}(())
240240
Base.one(::Type{S}) where {S <: ElementarySpace} = ProductSpace{S, 0}(())

test/symmetries/fusiontrees.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ using .TestSetup
578578
d1 = transpose(f1, f1, (N + 1, 1:N..., ((2N):-1:(N + 3))...), (N + 2,))
579579
f1front, = TK.split(f1, N - 1)
580580
T = sectorscalartype(I)
581-
d2 = Dict{typeof((f1front, f1front)),T}()
581+
d2 = Dict{typeof((f1front, f1front)), T}()
582582
for ((f1′, f2′), coeff′) in d1
583583
for ((f1′′, f2′′), coeff′′) in
584584
TK.planar_trace(

test/symmetries/spaces.jl

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,9 @@ end
291291
@test @constinferred((V1, V2, V3 V4)) == P
292292
@test @constinferred((V1, V2 V3, V4)) == P
293293
@test V1 * V2 * unitspace(V1) * V3 * V4 ==
294-
@constinferred(insertleftunit(P, 3)) ==
295-
@constinferred(insertrightunit(P, 2))
296-
@test @constinferred(removeunit(V1 * V2 * unitspace(V1)' * V3 * V4, 3)) == P
294+
@constinferred(insertleftunitspace(P, 3)) ==
295+
@constinferred(insertrightunitspace(P, 2))
296+
@test @constinferred(removeunitspace(V1 * V2 * unitspace(V1)' * V3 * V4, 3)) == P
297297
@test fuse(V1, V2', V3) V1 V2' V3
298298
@test fuse(V1, V2', V3) V1 V2' V3
299299
@test fuse(V1, V2', V3) V1 V2' V3
@@ -352,9 +352,9 @@ end
352352
@test @constinferred((V1, V2, V3)) == P
353353
@test @constinferred(adjoint(P)) == dual(P) == V3' V2' V1'
354354
@test V1 * V2 * unitspace(V1)' * V3 ==
355-
@constinferred(insertleftunit(P, 3; conj = true)) ==
356-
@constinferred(insertrightunit(P, 2; conj = true))
357-
@test P == @constinferred(removeunit(insertleftunit(P, 3), 3))
355+
@constinferred(insertleftunitspace(P, 3; conj = true)) ==
356+
@constinferred(insertrightunitspace(P, 2; conj = true))
357+
@test P == @constinferred(removeunitspace(insertleftunitspace(P, 3), 3))
358358
@test fuse(V1, V2', V3) V1 V2' V3
359359
@test fuse(V1, V2', V3) V1 V2' V3 fuse(V1 V2' V3)
360360
@test fuse(V1, V2') V3 V1 V2' V3
@@ -433,22 +433,22 @@ end
433433
@test permute(W, ((2, 4, 5), (3, 1))) == (V2 V4' V5' V3 V1')
434434
@test (V1 V2 V1 V2) == @constinferred TensorKit.compose(W, W')
435435
@test (V1 V2 V3 V4 V5 unitspace(V5)) ==
436-
@constinferred(insertleftunit(W)) ==
437-
@constinferred(insertrightunit(W))
438-
@test @constinferred(removeunit(insertleftunit(W), $(numind(W) + 1))) == W
436+
@constinferred(insertleftunitspace(W)) ==
437+
@constinferred(insertrightunitspace(W))
438+
@test @constinferred(removeunitspace(insertleftunitspace(W), $(numind(W) + 1))) == W
439439
@test (V1 V2 V3 V4 V5 unitspace(V5)') ==
440-
@constinferred(insertleftunit(W; conj = true)) ==
441-
@constinferred(insertrightunit(W; conj = true))
440+
@constinferred(insertleftunitspace(W; conj = true)) ==
441+
@constinferred(insertrightunitspace(W; conj = true))
442442
@test (unitspace(V1) V1 V2 V3 V4 V5) ==
443-
@constinferred(insertleftunit(W, 1)) ==
444-
@constinferred(insertrightunit(W, 0))
443+
@constinferred(insertleftunitspace(W, 1)) ==
444+
@constinferred(insertrightunitspace(W, 0))
445445
@test (V1 V2 unitspace(V1) V3 V4 V5) ==
446-
@constinferred(insertrightunit(W, 2))
446+
@constinferred(insertrightunitspace(W, 2))
447447
@test (V1 V2 unitspace(V1) V3 V4 V5) ==
448-
@constinferred(insertleftunit(W, 3))
449-
@test @constinferred(removeunit(insertleftunit(W, 3), 3)) == W
450-
@test @constinferred(insertrightunit(one(V1) V1, 0)) == (unitspace(V1) V1)
451-
@test_throws BoundsError insertleftunit(one(V1) V1, 0)
448+
@constinferred(insertleftunitspace(W, 3))
449+
@test @constinferred(removeunitspace(insertleftunitspace(W, 3), 3)) == W
450+
@test @constinferred(insertrightunitspace(one(V1) V1, 0)) == (unitspace(V1) V1)
451+
@test_throws BoundsError insertleftunitspace(one(V1) V1, 0)
452452
end
453453
end
454454

test/tensors/tensors.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ for V in spacelist
5050
next = @constinferred Nothing iterate(bs, state)
5151
b2 = @constinferred block(t, first(blocksectors(t)))
5252
@test b1 == b2
53-
@test eltype(bs) === Pair{typeof(c),typeof(b1)}
53+
@test eltype(bs) === Pair{typeof(c), typeof(b1)}
5454
@test typeof(b1) === TK.blocktype(t)
5555
@test typeof(c) === sectortype(t)
5656
end
@@ -112,7 +112,7 @@ for V in spacelist
112112
next = @constinferred Nothing iterate(bs, state)
113113
b2 = @constinferred block(t', first(blocksectors(t')))
114114
@test b1 == b2
115-
@test eltype(bs) === Pair{typeof(c),typeof(b1)}
115+
@test eltype(bs) === Pair{typeof(c), typeof(b1)}
116116
@test typeof(b1) === TK.blocktype(t')
117117
@test typeof(c) === sectortype(t)
118118
# linear algebra
@@ -156,20 +156,20 @@ for V in spacelist
156156
@test scalartype(t2) === T
157157
@test t.data === t2.data
158158
@test @constinferred(removeunitspace(t2, $(numind(t2)))) == t
159-
t3 = @constinferred insertleftunitspace(t; copy=true)
160-
@test t3 == @constinferred insertrightunitspace(t; copy=true)
159+
t3 = @constinferred insertleftunitspace(t; copy = true)
160+
@test t3 == @constinferred insertrightunitspace(t; copy = true)
161161
@test t.data !== t3.data
162162
for (c, b) in blocks(t)
163163
@test b == block(t3, c)
164164
end
165165
@test @constinferred(removeunitspace(t3, $(numind(t3)))) == t
166-
t4 = @constinferred insertrightunitspace(t, 3; dual=true)
166+
t4 = @constinferred insertrightunitspace(t, 3; dual = true)
167167
@test numin(t4) == numin(t) && numout(t4) == numout(t) + 1
168168
for (c, b) in blocks(t)
169169
@test b == block(t4, c)
170170
end
171171
@test @constinferred(removeunitspace(t4, 4)) == t
172-
t5 = @constinferred insertleftunitspace(t, 4; dual=true)
172+
t5 = @constinferred insertleftunitspace(t, 4; dual = true)
173173
@test numin(t5) == numin(t) + 1 && numout(t5) == numout(t)
174174
for (c, b) in blocks(t)
175175
@test b == block(t5, c)

0 commit comments

Comments
 (0)