From e429f78d905e7bea55c0f7aabfcce6e3f4958c72 Mon Sep 17 00:00:00 2001 From: Boris De Vos Date: Mon, 12 Oct 2026 11:22:23 +0200 Subject: [PATCH 1/4] remove oneunit check in show --- src/utility/show.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/utility/show.jl b/src/utility/show.jl index c73434ae3..86ab2210f 100644 --- a/src/utility/show.jl +++ b/src/utility/show.jl @@ -36,9 +36,9 @@ function Base.show(io::IO, ::MIME"text/plain", ψ::FiniteMPS) # special handling of edge spaces => don't print if trivial Vright = right_virtualspace(ψ, L) - right_trivial = Vright == oneunit(Vright) + right_trivial = isunitspace(Vright) Vleft = left_virtualspace(ψ, 1) - left_trivial = Vleft == oneunit(Vleft) + left_trivial = isunitspace(Vleft) right_trivial || println(io, "│ ", Vright) @@ -122,9 +122,9 @@ function Base.show(io::IO, ::MIME"text/plain", mpo::AbstractMPO) if isfinite(mpo) # special handling of edge spaces => don't print if trivial Vright = right_virtualspace(mpo, L) - right_trivial = Vright == oneunit(Vright) + right_trivial = isunitspace(Vright) Vleft = left_virtualspace(mpo, 1) - left_trivial = Vleft == oneunit(Vleft) + left_trivial = isunitspace(Vleft) right_trivial || println(io, "│ ", Vright) for i in reverse(1:L) From bea84faf7a426da85dac50c648876885f9fbcbd5 Mon Sep 17 00:00:00 2001 From: Boris De Vos Date: Mon, 12 Oct 2026 11:23:29 +0200 Subject: [PATCH 2/4] remove oneunit in tests and docs --- benchmark/MPSKitBenchmarks/scripts/setup_heisenberg.jl | 2 +- docs/src/examples/quantum1d/6.hubbard/index.md | 2 +- docs/src/examples/quantum1d/6.hubbard/main.ipynb | 4 ++-- examples/quantum1d/6.hubbard/main.jl | 2 +- test/algorithms/changebonds.jl | 2 +- test/groundstate/approximate.jl | 8 ++++---- test/hamiltonian/mixed.jl | 4 ++-- test/states/infinitemps.jl | 2 +- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/benchmark/MPSKitBenchmarks/scripts/setup_heisenberg.jl b/benchmark/MPSKitBenchmarks/scripts/setup_heisenberg.jl index 10fbd196c..0e5b801bb 100644 --- a/benchmark/MPSKitBenchmarks/scripts/setup_heisenberg.jl +++ b/benchmark/MPSKitBenchmarks/scripts/setup_heisenberg.jl @@ -23,7 +23,7 @@ function initial_state(H) @assert allequal(physicalspace(H)) pspace = physicalspace(H, 1) - A = rand(oneunit(pspace) ⊗ pspace^2 ← oneunit(pspace)) + A = rand(unitspace(pspace) ⊗ pspace^2 ← unitspace(pspace)) As = MPSKit.decompose_localmps(A) return FiniteMPS(repeat(As, length(H) ÷ 2)) end diff --git a/docs/src/examples/quantum1d/6.hubbard/index.md b/docs/src/examples/quantum1d/6.hubbard/index.md index 3c1031042..0ca1407ad 100644 --- a/docs/src/examples/quantum1d/6.hubbard/index.md +++ b/docs/src/examples/quantum1d/6.hubbard/index.md @@ -184,7 +184,7 @@ charges = fill(FermionParity(1) ⊠ U1Irrep(1) ⊠ SU2Irrep(0), 2); H_u1_su2 = MPSKit.add_physical_charge(H_u1_su2, charges); pspaces = physicalspace.(Ref(H_u1_su2), 1:2) -vspaces = [oneunit(eltype(pspaces)), first(pspaces)] +vspaces = [unitspace(eltype(pspaces)), first(pspaces)] psi = InfiniteMPS(pspaces, vspaces) psi = compute_groundstate(psi, H_u1_su2; expansionfactor = 1 / 3) E = real(expectation_value(psi, H_u1_su2)) / 2 diff --git a/docs/src/examples/quantum1d/6.hubbard/main.ipynb b/docs/src/examples/quantum1d/6.hubbard/main.ipynb index b1630b942..16b518855 100644 --- a/docs/src/examples/quantum1d/6.hubbard/main.ipynb +++ b/docs/src/examples/quantum1d/6.hubbard/main.ipynb @@ -261,7 +261,7 @@ "H_u1_su2 = MPSKit.add_physical_charge(H_u1_su2, charges);\n", "\n", "pspaces = physicalspace.(Ref(H_u1_su2), 1:2)\n", - "vspaces = [oneunit(eltype(pspaces)), first(pspaces)]\n", + "vspaces = [unitspace(eltype(pspaces)), first(pspaces)]\n", "psi = InfiniteMPS(pspaces, vspaces)\n", "psi = compute_groundstate(psi, H_u1_su2; expansionfactor = 1 / 3)\n", "E = real(expectation_value(psi, H_u1_su2)) / 2\n", @@ -499,4 +499,4 @@ }, "nbformat": 4, "nbformat_minor": 3 -} \ No newline at end of file +} diff --git a/examples/quantum1d/6.hubbard/main.jl b/examples/quantum1d/6.hubbard/main.jl index c3653cf2f..2482f3db7 100644 --- a/examples/quantum1d/6.hubbard/main.jl +++ b/examples/quantum1d/6.hubbard/main.jl @@ -122,7 +122,7 @@ charges = fill(FermionParity(1) ⊠ U1Irrep(1) ⊠ SU2Irrep(0), 2); H_u1_su2 = MPSKit.add_physical_charge(H_u1_su2, charges); pspaces = physicalspace.(Ref(H_u1_su2), 1:2) -vspaces = [oneunit(eltype(pspaces)), first(pspaces)] +vspaces = [unitspace(eltype(pspaces)), first(pspaces)] psi = InfiniteMPS(pspaces, vspaces) psi = compute_groundstate(psi, H_u1_su2; expansionfactor = 1 / 3) E = real(expectation_value(psi, H_u1_su2)) / 2 diff --git a/test/algorithms/changebonds.jl b/test/algorithms/changebonds.jl index 6ad5485d2..ab451e990 100644 --- a/test/algorithms/changebonds.jl +++ b/test/algorithms/changebonds.jl @@ -113,7 +113,7 @@ end H = kitaev_model(ComplexF64, Trivial; t = 1.0, mu = 0, Delta = 0, L = L) P = physicalspace(H)[1] S = typeof(P) - Vtriv = oneunit(P) + Vtriv = unitspace(P) Vodd = S(c => dim(P, c) for c in sectors(P) if !isone(c)) # single particle created on the last site: interior bonds carry only the even sector, so # the expansion content on them is exactly zero diff --git a/test/groundstate/approximate.jl b/test/groundstate/approximate.jl index 3b1ae7f8f..14e8d6801 100644 --- a/test/groundstate/approximate.jl +++ b/test/groundstate/approximate.jl @@ -23,7 +23,7 @@ end function _random_mpo_mps(pspace, Dspace, L; elt = ComplexF64) Random.seed!(1357) Wspace = Dspace - Vspaces = [oneunit(Wspace); fill(Wspace, L - 1); oneunit(Wspace)] + Vspaces = [unitspace(Wspace); fill(Wspace, L - 1); unitspace(Wspace)] O = FiniteMPO( [rand(ComplexF64, Vspaces[i] ⊗ pspace ← pspace ⊗ Vspaces[i + 1]) for i in 1:L] ) @@ -211,7 +211,7 @@ end @test info.truncation_errors ≈ info_ref.truncation_errors # a destination with unrelated contents is overwritten entirely - dst = FiniteMPS(rand, ComplexF64, length(ψ), pspace, oneunit(Dspace) ⊕ Dspace ⊕ Dspace) + dst = FiniteMPS(rand, ComplexF64, length(ψ), pspace, unitspace(Dspace) ⊕ Dspace ⊕ Dspace) got, info = approximate!(dst, (O, ψ), alg) @test norm(ref - got) / norm(ref) < 1.0e-12 @test info.truncation_errors ≈ info_ref.truncation_errors @@ -248,8 +248,8 @@ end @testset "Zip-up with non-square MPO $(spacetype(pspace))" for (pspace, Dspace, _) in zipup_spacelist Random.seed!(1357) L = 4 - pspace′ = pspace ⊕ oneunit(pspace) # output physical space, different from the input one - Vspaces = [oneunit(Dspace); fill(Dspace, L - 1); oneunit(Dspace)] + pspace′ = pspace ⊕ unitspace(pspace) # output physical space, different from the input one + Vspaces = [unitspace(Dspace); fill(Dspace, L - 1); unitspace(Dspace)] O = FiniteMPO( [rand(ComplexF64, Vspaces[i] ⊗ pspace′ ← pspace ⊗ Vspaces[i + 1]) for i in 1:L] ) diff --git a/test/hamiltonian/mixed.jl b/test/hamiltonian/mixed.jl index ebcb13ed6..7c6e0679f 100644 --- a/test/hamiltonian/mixed.jl +++ b/test/hamiltonian/mixed.jl @@ -91,7 +91,7 @@ Ts = fast_tests ? (Float64,) : (Float64, ComplexF64) ((i, i + 2) => h for i in 1:(L - 2))..., ((i, i + 3) => h for i in 1:(L - 3))..., ) - mps1 = FiniteMPS(physicalspace(H1), oneunit(V)) + mps1 = FiniteMPS(physicalspace(H1), unitspace(V)) for T in Ts H2 = if VERSION <= v"1.12" @@ -106,7 +106,7 @@ Ts = fast_tests ? (Float64,) : (Float64, ComplexF64) end H3 = InfiniteMPOHamiltonian(fill(V, L), (1, 2) => h, (1, 3) => h, (1, 4) => h) - mps2 = InfiniteMPS(physicalspace(H3), [oneunit(V)]) + mps2 = InfiniteMPS(physicalspace(H3), [unitspace(V)]) for T in Ts H4 = if VERSION <= v"1.12" # this is type unstable for LTS for some reason diff --git a/test/states/infinitemps.jl b/test/states/infinitemps.jl index 7ed6df550..1226c395d 100644 --- a/test/states/infinitemps.jl +++ b/test/states/infinitemps.jl @@ -101,7 +101,7 @@ end end # product state has zero entropy everywhere - ψ_product = InfiniteMPS([d, d], [oneunit(D), oneunit(D)]) + ψ_product = InfiniteMPS([d, d], [unitspace(D), unitspace(D)]) Ss_product = entropy(ψ_product) @test all(S -> isapprox(S, 0; atol = 1.0e-10), Ss_product) end From b264c82619e390deff09ad16a0accc8e6192aaa0 Mon Sep 17 00:00:00 2001 From: Boris De Vos Date: Mon, 12 Oct 2026 11:24:01 +0200 Subject: [PATCH 3/4] rightunitspace for hamiltonian in cluster exp --- src/algorithms/timestep/clusterexpansion.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/timestep/clusterexpansion.jl b/src/algorithms/timestep/clusterexpansion.jl index 44d38b083..cbaac31ed 100644 --- a/src/algorithms/timestep/clusterexpansion.jl +++ b/src/algorithms/timestep/clusterexpansion.jl @@ -95,7 +95,7 @@ end function exponentiate_onsite_tensor(ham_tensor, τ, ::Type{A}) where {A} physical_space = physicalspace(ham_tensor) - levels = ⊞(oneunit(physical_space)) + levels = ⊞(rightunitspace(physical_space)) blocktype = tensormaptype(spacetype(physical_space), 2, 2, A) tensor = SparseBlockTensorMap{blocktype}(undef, levels ⊗ physical_space ← physical_space ⊗ levels) onsite = removeunit(removeunit(ham_tensor[1, 1, 1, end], 4), 1) From 2aa92d4f6b2cf9d31eed0a2ea496ab7599e0a480 Mon Sep 17 00:00:00 2001 From: Boris De Vos Date: Mon, 12 Oct 2026 11:31:13 +0200 Subject: [PATCH 4/4] changelog --- docs/src/changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/src/changelog.md b/docs/src/changelog.md index 7efbec564..6005693f5 100644 --- a/docs/src/changelog.md +++ b/docs/src/changelog.md @@ -34,6 +34,7 @@ When releasing a new version, move the "Unreleased" changes to a new version sec ### Fixed - `convert(TensorMap, H)` for single-site `FiniteMPOHamiltonian`s no longer contracts the site tensor with itself. ([#252](https://github.com/QuantumKitHub/MPSKit.jl/pull/252)) +- `show` methods for finite MPS/MPOs no longer check unit space condition through `oneunit`, which is not defined for multifusion spaces. ([#538](https://github.com/QuantumKitHub/MPSKit.jl/pull/538)) ### Performance