Skip to content
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

[ITensors] [BUG] Error of replaceinds when the inds vector to be replaced is large #1078

Open
LinjianMa opened this issue Feb 27, 2023 · 0 comments
Labels
bug Something isn't working ITensors Issues or pull requests related to the `ITensors` package.

Comments

@LinjianMa
Copy link
Contributor

Description of bug

Error of replaceinds when the inds list to be replaced is large

Minimal code demonstrating the bug or unexpected behavior

Minimal runnable code

julia> using ITensors


julia> ninds = 101
101

julia> indices = [Index(2, "$(i)") for i in 1:ninds]
101-element Vector{Index{Int64}}:
 (dim=2|id=349|"1")
 (dim=2|id=406|"2")
 (dim=2|id=603|"3")
 (dim=2|id=141|"4")
 (dim=2|id=922|"5")
 (dim=2|id=678|"6")
 (dim=2|id=249|"7")
 (dim=2|id=710|"8")
 (dim=2|id=964|"9")
 (dim=2|id=616|"10")
 (dim=2|id=291|"11")
 (dim=2|id=741|"12")
 (dim=2|id=273|"13")
 (dim=2|id=292|"14")
 (dim=2|id=790|"15")
 (dim=2|id=30|"16")
 (dim=2|id=529|"17")
 (dim=2|id=32|"18")
 (dim=2|id=86|"19")
 (dim=2|id=395|"20")
 
 (dim=2|id=6|"82")
 (dim=2|id=658|"83")
 (dim=2|id=841|"84")
 (dim=2|id=222|"85")
 (dim=2|id=786|"86")
 (dim=2|id=786|"87")
 (dim=2|id=655|"88")
 (dim=2|id=767|"89")
 (dim=2|id=944|"90")
 (dim=2|id=916|"91")
 (dim=2|id=342|"92")
 (dim=2|id=332|"93")
 (dim=2|id=469|"94")
 (dim=2|id=372|"95")
 (dim=2|id=771|"96")
 (dim=2|id=622|"97")
 (dim=2|id=680|"98")
 (dim=2|id=19|"99")
 (dim=2|id=87|"100")
 (dim=2|id=293|"101")

julia> new_indices = [Index(2, "new$(i)") for i in 1:ninds]
101-element Vector{Index{Int64}}:
 (dim=2|id=565|"new1")
 (dim=2|id=535|"new2")
 (dim=2|id=755|"new3")
 (dim=2|id=401|"new4")
 (dim=2|id=854|"new5")
 (dim=2|id=767|"new6")
 (dim=2|id=968|"new7")
 (dim=2|id=102|"new8")
 (dim=2|id=384|"new9")
 (dim=2|id=648|"new10")
 (dim=2|id=489|"new11")
 (dim=2|id=602|"new12")
 (dim=2|id=55|"new13")
 (dim=2|id=565|"new14")
 (dim=2|id=224|"new15")
 (dim=2|id=593|"new16")
 (dim=2|id=930|"new17")
 (dim=2|id=988|"new18")
 (dim=2|id=548|"new19")
 (dim=2|id=327|"new20")
 
 (dim=2|id=532|"new82")
 (dim=2|id=944|"new83")
 (dim=2|id=634|"new84")
 (dim=2|id=230|"new85")
 (dim=2|id=571|"new86")
 (dim=2|id=655|"new87")
 (dim=2|id=547|"new88")
 (dim=2|id=593|"new89")
 (dim=2|id=619|"new90")
 (dim=2|id=302|"new91")
 (dim=2|id=181|"new92")
 (dim=2|id=360|"new93")
 (dim=2|id=466|"new94")
 (dim=2|id=598|"new95")
 (dim=2|id=541|"new96")
 (dim=2|id=678|"new97")
 (dim=2|id=294|"new98")
 (dim=2|id=267|"new99")
 (dim=2|id=756|"new100")
 (dim=2|id=878|"new101")

julia> a = ITensor(indices[1])
ITensor ord=1 (dim=2|id=349|"1")
NDTensors.EmptyStorage{NDTensors.EmptyNumber, NDTensors.Dense{NDTensors.EmptyNumber, Vector{NDTensors.EmptyNumber}}}

julia> replaceinds(a, indices, new_indices)
ITensor ord=1 (dim=2|id=565|"new1")
NDTensors.EmptyStorage{NDTensors.EmptyNumber, NDTensors.Dense{NDTensors.EmptyNumber, Vector{NDTensors.EmptyNumber}}}

julia> replaceinds(a, indices => new_indices)
ERROR: BoundsError: attempt to access 101-element Vector{Val} at index [102]
Stacktrace:
 [1] getindex
   @ ./array.jl:924 [inlined]
 [2] _Tuple(v::Vector{Index{Int64}})
   @ NDTensors ~/.julia/packages/NDTensors/0Qai0/src/tupletools.jl:7
 [3] Tuple
   @ ~/.julia/packages/ITensors/LXBUp/src/indexset.jl:70 [inlined]
 [4] replaceinds(is::Tuple{Index{Int64}}, rep_inds::Pair{Vector{Index{Int64}}, Vector{Index{Int64}}})
   @ ITensors ~/.julia/packages/ITensors/LXBUp/src/indexset.jl:560
 [5] replaceinds(A::NDTensors.EmptyTensor{NDTensors.EmptyNumber, 1, Tuple{Index{Int64}}, NDTensors.EmptyStorage{NDTensors.EmptyNumber, NDTensors.Dense{NDTensors.EmptyNumber, Vector{NDTensors.EmptyNumber}}}}, args::Pair{Vector{Index{Int64}}, Vector{Index{Int64}}}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ ITensors ~/.julia/packages/ITensors/LXBUp/src/itensor.jl:1508
 [6] replaceinds(A::NDTensors.EmptyTensor{NDTensors.EmptyNumber, 1, Tuple{Index{Int64}}, NDTensors.EmptyStorage{NDTensors.EmptyNumber, NDTensors.Dense{NDTensors.EmptyNumber, Vector{NDTensors.EmptyNumber}}}}, args::Pair{Vector{Index{Int64}}, Vector{Index{Int64}}})
   @ ITensors ~/.julia/packages/ITensors/LXBUp/src/itensor.jl:1507
 [7] replaceinds(A::ITensor, args::Pair{Vector{Index{Int64}}, Vector{Index{Int64}}}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ ITensors ~/.julia/packages/ITensors/LXBUp/src/itensor.jl:1504
 [8] replaceinds(A::ITensor, args::Pair{Vector{Index{Int64}}, Vector{Index{Int64}}})
   @ ITensors ~/.julia/packages/ITensors/LXBUp/src/itensor.jl:1504
 [9] top-level scope
   @ REPL[7]:1

Actual output or behavior

replaceinds(a, indices => new_indices)

doesn't work as expected, while

replaceinds(a, indices, new_indices)

works well.

Version information

  • Output from versioninfo():
julia> versioninfo()
Julia Version 1.8.2
Commit 36034abf260 (2022-09-29 15:21 UTC)
Platform Info:
  OS: macOS (arm64-apple-darwin21.3.0)
  CPU: 8 × Apple M1 Pro
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-13.0.1 (ORCJIT, apple-m1)
  Threads: 1 on 6 virtual cores
Environment:
  LD_LIBRARY_PATH = /opt/intel/oneapi/mkl/2021.2.0/lib:/usr/local/lib/:
  • Output from using Pkg; Pkg.status("ITensors"):
julia> using Pkg; Pkg.status("ITensors")
Status `~/.julia/environments/v1.8/Project.toml`
  [9136182c] ITensors v0.3.27
@LinjianMa LinjianMa added bug Something isn't working ITensors Issues or pull requests related to the `ITensors` package. labels Feb 27, 2023
@LinjianMa LinjianMa changed the title [ITensors] [BUG] Error of replaceinds when the inds list to be replaced is large [ITensors] [BUG] Error of replaceinds when the inds vector to be replaced is large Feb 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ITensors Issues or pull requests related to the `ITensors` package.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant