ITensor News


Stricter Keyword Argument Behavior

Nov 6, 2023

As of ITensors.jl v0.3.49, functions like dmrg, factorize, and svd are stricter about how they handle keyword arguments. Specifically, if you pass unsupported keyword arguments to them, they will now error instead of silently ignoring them, for example:

julia> using ITensors

julia> i, j = Index.((2, 2))
((dim=2|id=219), (dim=2|id=59))

julia> A = randomITensor(i, j)
ITensor ord=2 (dim=2|id=219) (dim=2|id=59)
NDTensors.Dense{Float64, Vector{Float64}}

julia> svd(A, i; bad_kwarg=true)
ERROR: MethodError: no method matching svd(::ITensor, ::Index{Int64}; bad_kwarg::Bool)

Closest candidates are:
  svd(::ITensor, ::Any...; leftdir, rightdir, lefttags, righttags, mindim, maxdim, cutoff, alg, use_absolute_cutoff, use_relative_cutoff, min_blockdim, utags, vtags) got unsupported keyword argument "bad_kwarg"
   @ ITensors ~/.julia/dev/ITensors/src/tensor_operations/matrix_decomposition.jl:109
  svd(::ITensor; kwargs...)
   @ ITensors ~/.julia/dev/ITensors/src/tensor_operations/matrix_decomposition.jl:201

Stacktrace:
 [1] kwerr(::NamedTuple{(:bad_kwarg,), Tuple{Bool}}, ::Function, ::ITensor, ::Index{Int64})
   @ Base ./error.jl:165
 [2] top-level scope
   @ REPL[4]:1
        

Most users should not be affected, but you may see errors show up in your codes if you update to that version, which you can fix by removing unsupported keyword arguments. This has led us to catch a few issues in downstream packages like ITensorGaussianMPS.jl and ITensorNetworks.jl where we were passing unsupported keyword arguments to ITensors.jl functions which we have fixed or are fixing now.