Skip to content

Commit e4ee03c

Browse files
lkdvosclaude
andauthored
Bump version to v0.3.19 (#79)
* Bump version to v0.3.19 * Adapt multifusion `SumSpace` to TensorKit v0.17.2 coloring rules TensorKit v0.17.2 (#515) requires every `GradedSpace` to be homogeneously colored, forbids `unitspace` for `GenericUnit` sectors and checks coloring when building `ProductSpace`/`HomSpace`. This broke the multifusion `SumSpace` tests, which flattened heterogeneous sums into a single `GradedSpace`. - `unitspace(::Type{<:SumSpace})` returns one component per simple unit - `leftunitspace`/`rightunitspace` inspect components instead of flattening - `_leftrightunit(::SumSpace)` uses the shared unit, or a wildcard if components differ - tests use `⊞` instead of flattening `⊕`, and expect incompatible products to throw - require TensorKit v0.17.2 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * Require multifusion SumSpace to be homogeneously colored as a whole The previous fix let leftunitspace/rightunitspace answer for a SumSpace whose components agreed on only one side (left xor right), by checking each side independently and treating disagreement on the other side as a wildcard. That's inconsistent with how a plain GradedSpace works: it is either homogeneously colored (single left AND right unit shared by every sector) or invalid. A SumSpace should follow the same rule as a whole, so leftunitspace/rightunitspace/_leftrightunit again require full agreement on both sides and reject (SpaceMismatch) otherwise, without any special-casing for a partial match. unitspace itself is unaffected by this: TensorKit already forbids it at the type level for GenericUnit sector types, regardless of any given instance's homogeneity, so it throws ArgumentError unconditionally for IsingBimodule-sectored spaces, homogeneous or not. The Multifusion testset is adjusted to expect this throughout, rather than the previous attempt to give unitspace a real answer for such sector types. --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent 2a04bdc commit e4ee03c

3 files changed

Lines changed: 40 additions & 20 deletions

File tree

‎Project.toml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "BlockTensorKit"
22
uuid = "5f87ffc2-9cf1-4a46-8172-465d160bd8cd"
3-
version = "0.3.18"
3+
version = "0.3.19"
44
authors = ["Lukas Devos <ldevos98@gmail.com> and contributors"]
55

66
[deps]
@@ -36,7 +36,7 @@ MatrixAlgebraKit = "0.6"
3636
Random = "1"
3737
SafeTestsets = "0.1"
3838
Strided = "2.3.3"
39-
TensorKit = "0.17"
39+
TensorKit = "0.17.2"
4040
TensorOperations = "5"
4141
Test = "1"
4242
TestExtras = "0.2, 0.3"

‎src/vectorspaces/sumspace.jl‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,18 @@ function TensorKit.rightunitspace(S::SumSpace)
180180
end
181181
TensorKit.isunitspace(S::SumSpace) = !isempty(S) && all(isunitspace, S.spaces)
182182

183+
# a `SumSpace` must, as a whole, be homogeneously colored: all of its sectors (across all
184+
# components) share a single left and right unit, exactly like a plain `GradedSpace`.
185+
function TK._leftrightunit(S::SumSpace)
186+
s = sectors(S)
187+
isempty(s) && return (nothing, nothing)
188+
c = first(s)
189+
l, r = TK.leftunit(c), TK.rightunit(c)
190+
all(x -> TK.leftunit(x) == l && TK.rightunit(x) == r, s) ||
191+
throw(SpaceMismatch(lazy"components of $S do not share a single left and right unit"))
192+
return (l, r)
193+
end
194+
183195
# Promotion and conversion
184196
# ------------------------
185197
Base.promote_rule(::Type{S}, ::Type{SumSpace{S}}) where {S <: ElementarySpace} = SumSpace{S}

‎test/vectorspaces/sumspace.jl‎

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ end
160160
using Test, TestExtras
161161

162162
using TensorKit: hassector
163-
using BlockTensorKit: ⊕
164163

165164
I = IsingBimodule
166165

@@ -186,7 +185,9 @@ end
186185
@test @constinferred(dual(V)) == @constinferred(conj(V)) == @constinferred(adjoint(V))
187186
@test field(V) == ℂ
188187

189-
@test unitspace(V) == unitspace(V1)
188+
@test_throws ArgumentError unitspace(V1)
189+
@test_throws ArgumentError unitspace(V)
190+
@test_throws ArgumentError unitspace(SumSpace(V1))
190191

191192
@test @constinferred(sectortype(V)) == sectortype(V1)
192193
@test ((@constinferred sectors(V))...,) == (C0, C1, M, D0, D1) # sorted order
@@ -208,20 +209,26 @@ end
208209
for W in [WC, WD]
209210
@test isunitspace(W)
210211
@test W == @constinferred(leftunitspace(W)) == @constinferred(rightunitspace(W))
211-
@test unitspace(typeof(W)) == ⊞(Vect[IsingBimodule]((1, 1, 0) => 1, (2, 2, 0) => 1))
212+
@test_throws ArgumentError unitspace(typeof(W))
212213
end
213214

214-
@test_throws ArgumentError leftunitspace(V)
215-
@test_throws ArgumentError rightunitspace(V)
216-
@test leftunitspace(SumSpace(V1, V3)) == WC
217-
@test rightunitspace(SumSpace(V2, V3)) == WD
215+
# a `SumSpace` is only well-defined as a single left/right unit when ALL of its
216+
# components, taken together, are homogeneously colored -- exactly like a plain
217+
# `GradedSpace`. Combinations that mix components with different left and/or right
218+
# units are rejected, even if they happen to agree on one side.
219+
@test_throws SpaceMismatch leftunitspace(V)
220+
@test_throws SpaceMismatch rightunitspace(V)
221+
@test_throws SpaceMismatch leftunitspace(SumSpace(V1, V3))
222+
@test_throws SpaceMismatch rightunitspace(SumSpace(V2, V3))
218223
@test leftunitspace(WMop) == WD && rightunitspace(WMop) == WC
219224
@test leftunitspace(WM) == WC && rightunitspace(WM) == WD
220-
@test unitspace(WM) == unitspace(WMop) == ⊞(Vect[IsingBimodule]((1, 1, 0) => 1, (2, 2, 0) => 1))
225+
@test_throws ArgumentError unitspace(WM)
226+
@test_throws ArgumentError unitspace(WMop)
221227

222228
Wempty = SumSpace(Vect[I]())
223229
Wzero = zerospace(V)
224-
@test unitspace(Wempty) == unitspace(Wzero)
230+
@test_throws ArgumentError unitspace(Wempty)
231+
@test_throws ArgumentError unitspace(Wzero)
225232
for f in (leftunitspace, rightunitspace)
226233
@test_throws ArgumentError f(Wempty)
227234
end
@@ -231,9 +238,9 @@ end
231238
VMD = SumSpace(V2, V3)
232239

233240
@test @constinferred(⊞(V, V)) == SumSpace(vcat(V.spaces, V.spaces))
234-
@test @constinferred(⊞(VCM, unitspace(VCM))) == SumSpace(vcat(VCM.spaces, unitspace(VCM).spaces))
235-
@test @constinferred(⊞(VCM, leftunitspace(VCM))) == SumSpace(vcat(VCM.spaces, leftunitspace(VCM).spaces))
236-
@test @constinferred(⊞(VMD, rightunitspace(VMD))) == SumSpace(vcat(VMD.spaces, rightunitspace(VMD).spaces))
241+
@test_throws ArgumentError unitspace(VCM)
242+
@test_throws SpaceMismatch leftunitspace(VCM)
243+
@test_throws SpaceMismatch rightunitspace(VMD)
237244

238245
@test @constinferred(⊞(V, V, V, V)) == SumSpace(repeat(V.spaces, 4))
239246
@test @constinferred(fuse(VC, VC)) ≅ SumSpace(Vect[I](C0 => 8, C1 => 8))
@@ -243,18 +250,19 @@ end
243250
@test flip(V) ≅ V
244251
@test flip(V) ≾ V
245252
@test flip(V) ≿ V
246-
@test V ≺ ⊕(V, V)
247-
@test !(V ≻ ⊕(V, V))
253+
@test V ≺ ⊞(V, V)
254+
@test !(V ≻ ⊞(V, V))
248255

249256
# blocksectors tests
250257
@test issetequal(@constinferred(blocksectors(one(V) ← one(V))), (C0, D0))
251-
@test issetequal(@constinferred(blocksectors(V ← V)), sectors(V))
258+
@test_throws SpaceMismatch V ← V # `V` itself is not homogeneously colored
252259
@test @constinferred(blocksectors(one(V))) == [C0, D0]
253-
for v in [VC, VCM, VMD]
254-
@test issetequal(@constinferred(blocksectors(v^2)), blocksectors(v ← v))
260+
@test issetequal(@constinferred(blocksectors(VC^2)), blocksectors(VC ← VC))
261+
for v in [VCM, VMD]
262+
@test_throws SpaceMismatch v^2 # not homogeneously colored
255263
end
256264
for v in [WM, WMop]
257-
@test isempty(@constinferred(blocksectors(v^2)))
265+
@test_throws SpaceMismatch v^2
258266
@test issetequal(@constinferred(blocksectors(v ← v)), blocksectors(v))
259267
end
260268
end

0 commit comments

Comments
 (0)