-
Notifications
You must be signed in to change notification settings - Fork 45
[Feature] Update show methods to reflect new TensorKit printing #341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
I liked the old 10-site FiniteMPS (ComplexF64, ComplexSpace):
┌ C[10]: TensorMap(ℂ^1 ← ℂ^1)
├── AL[10]: TensorMap((ℂ^2 ⊗ ℂ^2) ← ℂ^1)
├── AL[9]: TensorMap((ℂ^4 ⊗ ℂ^2) ← ℂ^2)
├── AL[8]: TensorMap((ℂ^8 ⊗ ℂ^2) ← ℂ^4)
├── AL[7]: TensorMap((ℂ^16 ⊗ ℂ^2) ← ℂ^8)
├── AL[6]: TensorMap((ℂ^32 ⊗ ℂ^2) ← ℂ^16)
├── AL[5]: TensorMap((ℂ^16 ⊗ ℂ^2) ← ℂ^32)
├── AL[4]: TensorMap((ℂ^8 ⊗ ℂ^2) ← ℂ^16)
├── AL[3]: TensorMap((ℂ^4 ⊗ ℂ^2) ← ℂ^8)
├── AL[2]: TensorMap((ℂ^2 ⊗ ℂ^2) ← ℂ^4)
└── AL[1]: TensorMap((ℂ^1 ⊗ ℂ^2) ← ℂ^2)Way more concise :/ |
Codecov Report❌ Patch coverage is
... and 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
|
Unfortunately, the new |
|
I didn't realise the |
|
Some updated suggestions: DetailsHere I've more or less restored the old approach by simply printing spaces instead: julia> psi = FiniteMPS(5, ℂ^2, ℂ^10)
5-site FiniteMPS (ComplexF64, ComplexSpace) with maximal dimension 4:
┌ C[5]: ℂ^1 ← ℂ^1
┌── AL[5]: (ℂ^2 ⊗ ℂ^2) ← ℂ^1
├── AL[4]: (ℂ^4 ⊗ ℂ^2) ← ℂ^2
├── AL[3]: (ℂ^4 ⊗ ℂ^2) ← ℂ^4
├── AL[2]: (ℂ^2 ⊗ ℂ^2) ← ℂ^4
└── AL[1]: (ℂ^1 ⊗ ℂ^2) ← ℂ^2Here I've condensed everything even further, avoiding printing the same virtualspace twice julia> psi = FiniteMPS(40, ℂ^2, ℂ^50)
40-site FiniteMPS (ComplexF64, ComplexSpace) with center 81/2:
┌─[40]─ ℂ^2
│ ℂ^2
├─[39]─ ℂ^2
│ ℂ^4
├─[38]─ ℂ^2
│ ℂ^8
├─[37]─ ℂ^2
│ ℂ^16
├─[36]─ ℂ^2
│ ℂ^32
├─[35]─ ℂ^2
│ ℂ^50
├─[34]─ ℂ^2
│ ℂ^50
├─[33]─ ℂ^2
│ ℂ^50
├─[32]─ ℂ^2
│ ℂ^50
├─[31]─ ℂ^2
│ ℂ^50
├─[30]─ ℂ^2
│ ℂ^50
├─[29]─ ℂ^2
│ ⋮
│ ℂ^50
├─[11]─ ℂ^2
│ ℂ^50
├─[10]─ ℂ^2
│ ℂ^50
├─[9]─ ℂ^2
│ ℂ^50
├─[8]─ ℂ^2
│ ℂ^50
├─[7]─ ℂ^2
│ ℂ^50
├─[6]─ ℂ^2
│ ℂ^32
├─[5]─ ℂ^2
│ ℂ^16
├─[4]─ ℂ^2
│ ℂ^8
├─[3]─ ℂ^2
│ ℂ^4
├─[2]─ ℂ^2
│ ℂ^2
└─[1]─ ℂ^2
julia> psi = FiniteMPS(40, SU2Space(1 => 1), SU2Space(i => 10 for i in 0:5))
40-site FiniteMPS (ComplexF64, Rep[SU₂]) with center 81/2:
┌─[40]─ (1=>1)
│ (1=>1)
├─[39]─ (1=>1)
│ (0=>1, 1=>1, 2=>1)
├─[38]─ (1=>1)
│ (0=>1, 1=>3, 2=>2, 3=>1)
├─[37]─ (1=>1)
│ (0=>3, 1=>6, 2=>6, 3=>3, 4=>1)
├─[36]─ (1=>1)
│ (0=>6, 1=>10, 2=>10, 3=>10, 4=>4, 5=>1)
├─[35]─ (1=>1)
│ (0=>10, 1=>10, 2=>10, 3=>10, 4=>10, 5=>5)
├─[34]─ (1=>1)
│ (0=>10, 1=>10, 2=>10, 3=>10, 4=>10, 5=>10)
├─[33]─ (1=>1)
│ (0=>10, 1=>10, 2=>10, 3=>10, 4=>10, 5=>10)
├─[32]─ (1=>1)
│ (0=>10, 1=>10, 2=>10, 3=>10, 4=>10, 5=>10)
├─[31]─ (1=>1)
│ (0=>10, 1=>10, 2=>10, 3=>10, 4=>10, 5=>10)
├─[30]─ (1=>1)
│ (0=>10, 1=>10, 2=>10, 3=>10, 4=>10, 5=>10)
├─[29]─ (1=>1)
│ ⋮
│ (0=>10, 1=>10, 2=>10, 3=>10, 4=>10, 5=>10)
├─[11]─ (1=>1)
│ (0=>10, 1=>10, 2=>10, 3=>10, 4=>10, 5=>10)
├─[10]─ (1=>1)
│ (0=>10, 1=>10, 2=>10, 3=>10, 4=>10, 5=>10)
├─[9]─ (1=>1)
│ (0=>10, 1=>10, 2=>10, 3=>10, 4=>10, 5=>10)
├─[8]─ (1=>1)
│ (0=>10, 1=>10, 2=>10, 3=>10, 4=>10, 5=>10)
├─[7]─ (1=>1)
│ (0=>10, 1=>10, 2=>10, 3=>10, 4=>10, 5=>5)
├─[6]─ (1=>1)
│ (0=>6, 1=>10, 2=>10, 3=>10, 4=>4, 5=>1)
├─[5]─ (1=>1)
│ (0=>3, 1=>6, 2=>6, 3=>3, 4=>1)
├─[4]─ (1=>1)
│ (0=>1, 1=>3, 2=>2, 3=>1)
├─[3]─ (1=>1)
│ (0=>1, 1=>1, 2=>1)
├─[2]─ (1=>1)
│ (1=>1)
└─[1]─ (1=>1)I quite like the last approach since I always had a hard time parsing the spaces, but it might not be super obvious what everything is anymore... |
|
I like these examples very much. The last 2 are indeed way more clear, I do like the maximal dimension note shown in the first example. |
|
Some (hopefully) final changes: Detailsjulia> psi = repeat(InfiniteMPS(2, 12), 2)
2-site InfiniteMPS(ComplexF64, ComplexSpace) maxdim = 12:
| ⋮
│ ℂ^12
├─[2]─ ℂ^2
│ ℂ^12
├─[1]─ ℂ^2
│ ℂ^12
| ⋮
julia> H = repeat(InfiniteMPOHamiltonian(rand(ℂ^2⊗ℂ^2, ℂ^2⊗ℂ^2)), 2)
2-site InfiniteMPOHamiltonian(Float64, ComplexSpace) maxdim = 6:
| ⋮
| (ℂ^1 ⊞ ℂ^4 ⊞ ℂ^1)
┼─[2]─ ℂ^2
│ (ℂ^1 ⊞ ℂ^4 ⊞ ℂ^1)
┼─[1]─ ℂ^2
│ (ℂ^1 ⊞ ℂ^4 ⊞ ℂ^1)
| ⋮
julia> environments(psi, H)
2-site MPSKit.InfiniteEnvironments{BlockTensorKit.BlockTensorMap{TensorMap{ComplexF64, ComplexSpace, 2, 1, Vector{ComplexF64}}, ComplexF64, ComplexSpace, 2, 1, 3}}:
GL[1]: (⊞(ℂ^12) ⊗ ((ℂ^1)' ⊞ (ℂ^4)' ⊞ (ℂ^1)')) ← ⊞(ℂ^12)
GL[2]: (⊞(ℂ^12) ⊗ ((ℂ^1)' ⊞ (ℂ^4)' ⊞ (ℂ^1)')) ← ⊞(ℂ^12)
GR[1]: (⊞(ℂ^12) ⊗ (ℂ^1 ⊞ ℂ^4 ⊞ ℂ^1)) ← ⊞(ℂ^12)
GR[2]: (⊞(ℂ^12) ⊗ (ℂ^1 ⊞ ℂ^4 ⊞ ℂ^1)) ← ⊞(ℂ^12)
julia> psi = FiniteMPS(6, ℂ^2, ℂ^4)
6-site FiniteMPS (ComplexF64, ComplexSpace) maxdim = 4 center = 13/2:
┌─[6]─ ℂ^2
│ ℂ^2
├─[5]─ ℂ^2
│ ℂ^4
├─[4]─ ℂ^2
│ ℂ^4
├─[3]─ ℂ^2
│ ℂ^4
├─[2]─ ℂ^2
│ ℂ^2
└─[1]─ ℂ^2
julia> H = open_boundary_conditions(H, length(psi))
6-site FiniteMPOHamiltonian(Float64, ComplexSpace) maxdim = 6:
┬─[6]─ ℂ^2
│ (ℂ^1 ⊞ ℂ^4 ⊞ ℂ^1)
┼─[5]─ ℂ^2
│ (ℂ^1 ⊞ ℂ^4 ⊞ ℂ^1)
┼─[4]─ ℂ^2
│ (ℂ^1 ⊞ ℂ^4 ⊞ ℂ^1)
┼─[3]─ ℂ^2
│ (ℂ^1 ⊞ ℂ^4 ⊞ ℂ^1)
┼─[2]─ ℂ^2
│ (ℂ^1 ⊞ ℂ^4 ⊞ ℂ^1)
┴─[1]─ ℂ^2
julia> environments(psi, H)
7-site environments(state, ::FiniteMPOHamiltonian{JordanMPOTensorMap{Float64, ComplexSpace, Vector{Float64}}}):
GL[1]: (⊞(ℂ^1) ⊗ ⊞((ℂ^1)')) ← ⊞(ℂ^1)
GL[2]: (⊞(ℂ^1) ⊗ ⊞((ℂ^1)')) ← ⊞(ℂ^1)
GL[3]: (⊞(ℂ^1) ⊗ ⊞((ℂ^1)')) ← ⊞(ℂ^1)
GL[4]: (⊞(ℂ^1) ⊗ ⊞((ℂ^1)')) ← ⊞(ℂ^1)
GL[5]: (⊞(ℂ^1) ⊗ ⊞((ℂ^1)')) ← ⊞(ℂ^1)
GL[6]: (⊞(ℂ^1) ⊗ ⊞((ℂ^1)')) ← ⊞(ℂ^1)
GL[7]: (⊞(ℂ^1) ⊗ ⊞((ℂ^1)')) ← ⊞(ℂ^1)
GR[1]: (⊞(ℂ^1) ⊗ ⊞(ℂ^1)) ← ⊞(ℂ^1)
GR[2]: (⊞(ℂ^1) ⊗ ⊞(ℂ^1)) ← ⊞(ℂ^1)
GR[3]: (⊞(ℂ^1) ⊗ ⊞(ℂ^1)) ← ⊞(ℂ^1)
GR[4]: (⊞(ℂ^1) ⊗ ⊞(ℂ^1)) ← ⊞(ℂ^1)
GR[5]: (⊞(ℂ^1) ⊗ ⊞(ℂ^1)) ← ⊞(ℂ^1)
GR[6]: (⊞(ℂ^1) ⊗ ⊞(ℂ^1)) ← ⊞(ℂ^1)
GR[7]: (⊞(ℂ^1) ⊗ ⊞(ℂ^1)) ← ⊞(ℂ^1) |
|
Magnificent. Never thought i'd see the day where environments would be pretty printed :) |
|
|
Also this one seems off to me, the virtual space being constant across the sites, and especially not matching the virtual space of the finite state or Hamiltonian above doesn't seem right?
|
|
The spaces not matching is because I think I've addressed the other comments. Detailsjulia> psi = repeat(InfiniteMPS(2, 12), 2)
2-site InfiniteMPS(ComplexF64, ComplexSpace) with maximal dimension 12:
| ⋮
| ℂ^12
├─[2]─ ℂ^2
│ ℂ^12
├─[1]─ ℂ^2
│ ℂ^12
| ⋮
julia> H = repeat(InfiniteMPOHamiltonian(rand(ℂ^2⊗ℂ^2, ℂ^2⊗ℂ^2)), 2)
2-site InfiniteMPOHamiltonian(Float64, ComplexSpace) with maximal dimension 6:
| ⋮
| (ℂ^1 ⊞ ℂ^4 ⊞ ℂ^1)
┼─[2]─ ℂ^2
│ (ℂ^1 ⊞ ℂ^4 ⊞ ℂ^1)
┼─[1]─ ℂ^2
│ (ℂ^1 ⊞ ℂ^4 ⊞ ℂ^1)
| ⋮
julia> environments(psi, H)
2-site MPSKit.InfiniteEnvironments{BlockTensorKit.BlockTensorMap{TensorMap{ComplexF64, ComplexSpace, 2, 1, Vector{ComplexF64}}, ComplexF64, ComplexSpace, 2, 1, 3}}:
GL[2]: (⊞(ℂ^12) ⊗ ((ℂ^1)' ⊞ (ℂ^4)' ⊞ (ℂ^1)')) ← ⊞(ℂ^12)
GL[1]: (⊞(ℂ^12) ⊗ ((ℂ^1)' ⊞ (ℂ^4)' ⊞ (ℂ^1)')) ← ⊞(ℂ^12)
GR[2]: (⊞(ℂ^12) ⊗ (ℂ^1 ⊞ ℂ^4 ⊞ ℂ^1)) ← ⊞(ℂ^12)
GR[1]: (⊞(ℂ^12) ⊗ (ℂ^1 ⊞ ℂ^4 ⊞ ℂ^1)) ← ⊞(ℂ^12)
julia> psi = FiniteMPS(6, ℂ^2, ℂ^4)
6-site FiniteMPS(ComplexF64, ComplexSpace) with maximal dimension 4 and center 13/2:
┌─[6]─ ℂ^2
│ ℂ^2
├─[5]─ ℂ^2
│ ℂ^4
├─[4]─ ℂ^2
│ ℂ^4
├─[3]─ ℂ^2
│ ℂ^4
├─[2]─ ℂ^2
│ ℂ^2
└─[1]─ ℂ^2
julia> H = open_boundary_conditions(H, length(psi))
6-site FiniteMPOHamiltonian(Float64, ComplexSpace) with maximal dimension 6:
┬─[6]─ ℂ^2
│ (ℂ^1 ⊞ ℂ^4 ⊞ ℂ^1)
┼─[5]─ ℂ^2
│ (ℂ^1 ⊞ ℂ^4 ⊞ ℂ^1)
┼─[4]─ ℂ^2
│ (ℂ^1 ⊞ ℂ^4 ⊞ ℂ^1)
┼─[3]─ ℂ^2
│ (ℂ^1 ⊞ ℂ^4 ⊞ ℂ^1)
┼─[2]─ ℂ^2
│ (ℂ^1 ⊞ ℂ^4 ⊞ ℂ^1)
┴─[1]─ ℂ^2
julia> environments(psi, H)
7-site MPSKit.FiniteEnvironments{Nothing, FiniteMPOHamiltonian{JordanMPOTensorMap{Float64, ComplexSpace, Vector{Float64}}}, TensorMap{ComplexF64, ComplexSpace, 2, 1, Vector{ComplexF64}}, BlockTensorKit.BlockTensorMap{TensorMap{ComplexF64, ComplexSpace, 2, 1, Vector{ComplexF64}}, ComplexF64, ComplexSpace, 2, 1, 3}}:
GL[7]: (⊞(ℂ^1) ⊗ ⊞((ℂ^1)')) ← ⊞(ℂ^1)
GL[6]: (⊞(ℂ^1) ⊗ ⊞((ℂ^1)')) ← ⊞(ℂ^1)
GL[5]: (⊞(ℂ^1) ⊗ ⊞((ℂ^1)')) ← ⊞(ℂ^1)
GL[4]: (⊞(ℂ^1) ⊗ ⊞((ℂ^1)')) ← ⊞(ℂ^1)
GL[3]: (⊞(ℂ^1) ⊗ ⊞((ℂ^1)')) ← ⊞(ℂ^1)
GL[2]: (⊞(ℂ^1) ⊗ ⊞((ℂ^1)')) ← ⊞(ℂ^1)
GL[1]: (⊞(ℂ^1) ⊗ ⊞((ℂ^1)')) ← ⊞(ℂ^1)
GR[7]: (⊞(ℂ^1) ⊗ ⊞(ℂ^1)) ← ⊞(ℂ^1)
GR[6]: (⊞(ℂ^1) ⊗ ⊞(ℂ^1)) ← ⊞(ℂ^1)
GR[5]: (⊞(ℂ^1) ⊗ ⊞(ℂ^1)) ← ⊞(ℂ^1)
GR[4]: (⊞(ℂ^1) ⊗ ⊞(ℂ^1)) ← ⊞(ℂ^1)
GR[3]: (⊞(ℂ^1) ⊗ ⊞(ℂ^1)) ← ⊞(ℂ^1)
GR[2]: (⊞(ℂ^1) ⊗ ⊞(ℂ^1)) ← ⊞(ℂ^1)
GR[1]: (⊞(ℂ^1) ⊗ ⊞(ℂ^1)) ← ⊞(ℂ^1) |
Some modifications to make sure everything is printing as it should be.
Examples:
Details