I am trying to do something fairly simple but am having some trouble with the usage.
I am looking at replacetags! as it applies to MPS. The documentation does not contain any replacetags! MPS examples (that I could find) and I’m not able to infer from the source code what args is supposed to be.
Here is a MWE.
Any advice on how to achieve this would be appreciated.
begin
d = 2
N = 5
n = d^N
x = LinRange(2, 6, n)
f = x
inds = siteinds(d, N)
MWE = MPS(f, inds) # Has default "Link,n=#"
newlinktags = ["α,n=$(i)" for i = 1:(N-1)]
replacetags!(linkinds, MWE, newlinktags) # throws error, see below
end
This gives the following error.
ERROR: MethodError: no method matching replacetags(::Vector{Index{Int64}}, ::Vector{String})
Closest candidates are:
replacetags(::Union{Tuple{Vararg{IndexT}}, Vector{IndexT}} where IndexT<:Index, ::Any, ::Any, ::Any...; kwargs...) at ~/.julia/packages/ITensors/fpBnt/src/indexset.jl:512
replacetags(::Union{Tuple{Vararg{IndexT}}, Vector{IndexT}} where IndexT<:Index, ::Pair...; kwargs...) at ~/.julia/packages/ITensors/fpBnt/src/indexset.jl:505
replacetags(::ITensors.AbstractMPS, ::Any...; set_limits, kwargs...) at ~/.julia/packages/ITensors/fpBnt/src/mps/abstractmps.jl:722
Agreed that we need some code examples for this! Thanks for letting us know. Please let us know below if Ryan’s solution does not quite do what you need, but it looks correct to me.
Do you know how to replace the part of the tag associated with the site number?
For example, randomMPS returns an MPS with bond indices denoted by Link,l=1 while the MPS constructor will return all sites with n=1 in the tag. How could I replace the l= part of the tags in the MPS returned by randomMPS? (just for consistency)
In other words, go from Link,l=# to Link,n=#? I tried replacetags!(randMPS, "l=" => "n=") but it does not appear to change anything.