+1 vote
asked by (210 points)


I'm new to ITensors and try to mainly use the DMRG features here. I found the DMRGObserver feature pretty useful and was trying to implement it according to the documentation here . However, I saw an error while trying to create the DMRGObserver.

DMRGObserver(energy_tol = 1e-5, minsweeps = 2)

The error reads:

    ERROR: MethodError: no method matching DMRGObserver(; energy_tol=1.0e-5, minsweeps=2)
Closest candidates are:
  DMRGObserver() at C:\Users\Sherry\.julia\packages\ITensors\2Rd6c\src\mps\observer.jl:33 got unsupported keyword arguments "energy_tol", "minsweeps"
  DMRGObserver(::Array{String,1}, ::Array{var"#s305",1} where var"#s305"<:Index; energy_tol, minsweeps) at C:\Users\Sherry\.julia\packages\ITensors\2Rd6c\src\mps\observer.jl:38
  DMRGObserver(::Any) at C:\Users\Sherry\.julia\packages\ITensors\2Rd6c\src\mps\observer.jl:33 got unsupported keyword arguments "energy_tol", "minsweeps"

Then I simply tried DMRGObserver(), still it gives the error

ERROR: MethodError: no method matching Array{var"#s305",1} where var"#s305"<:Index(::Array{Any,1})
 [1] convert(::Type{Array{var"#s305",1} where var"#s305"<:Index}, ::Array{Any,1}) at .\array.jl:554
 [2] DMRGObserver(::Float64, ::Int64) at C:\Users\Sherry\.julia\packages\ITensors\2Rd6c\src\mps\observer.jl:35 (repeats 2 times)
 [3] top-level scope at REPL[8]:1

I'm using the most up-to-date version of ITensors (0.1.34). I don't have a good idea on how to fix it from here on. Please let me know if you have any suggestions.


1 Answer

0 votes
answered by (52.6k points)

Hi Sherry, so that documentation was a little bit hard to understand, because it makes it appear as if those arguments are named arguments. They are (or were - see below) not named arguments but just default arguments. However, that constructor turned out to have another bug, so would not have worked anyway even if called correctly.

I used that situation as an opportunity to improve the interface, and now it should work as you'd expect, i.e.

DMRGObserver(; energy_tol = 1E-4, minsweeps = 2)

say. Note that this is true right now only for the master branch of ITensors.jl and isn't in the latest numbered version yet. But we will tag a new version soon and the change will be included in 0.1.35.


commented by (210 points)
Hi Miles,

I see. Now I use a similar construction function as the example and it works. Initially, I just wanted to use it to set a stop criterion without measuring any observables. Seems like for now I have to put some observable and sites here in order to use it?

commented by (52.6k points)
Yes, that's correct if by "for now" you mean for version 0.1.34 of ITensors. But we are tagging a new version 0.1.35 currently that should be available by tomorrow at the latest, and then you can use the more basic DMRGObserver constructor too.

Welcome to ITensor Support Q&A, where you can ask questions and receive answers from other members of the community.

Formatting Tips:
  • To format code, indent by four spaces
  • To format inline LaTeX, surround it by @@ on both sides
  • To format LaTeX on its own line, surround it by $$ above and below
  • For LaTeX, it may be necessary to backslash-escape underscore characters to obtain proper formatting. So for example writing \sum\_i to represent a sum over i.
If you cannot register due to firewall issues (e.g. you cannot see the capcha box) please email Miles Stoudenmire to ask for an account.

To report ITensor bugs, please use the issue tracker.