diff --git a/src/lib/ITensorMPS/src/deprecated.jl b/src/lib/ITensorMPS/src/deprecated.jl index d504a20d33..c0fc43a6c9 100644 --- a/src/lib/ITensorMPS/src/deprecated.jl +++ b/src/lib/ITensorMPS/src/deprecated.jl @@ -24,6 +24,18 @@ # mps/mps.jl @deprecate randomMPS(args...; kwargs...) random_mps(args...; kwargs...) +# Deprecated syntax for specifying link dimensions. +@deprecate randomMPS(elt::Type{<:Number}, sites::Vector{<:Index}, state, linkdims::Integer) random_mps( + elt, sites, state; linkdims +) +@deprecate randomMPS(elt::Type{<:Number}, sites::Vector{<:Index}, linkdims::Integer) random_mps( + elt, sites; linkdims +) +@deprecate randomMPS(sites::Vector{<:Index}, state, linkdims::Integer) random_mps( + sites, state; linkdims +) +@deprecate randomMPS(sites::Vector{<:Index}, linkdims::Integer) random_mps(sites; linkdims) + # Pass throughs of old name to new name: unique_siteind(A::AbstractMPS, B::AbstractMPS, j::Integer) = siteinds(uniqueind, A, B, j) diff --git a/src/lib/ITensorMPS/test/base/test_deprecated.jl b/src/lib/ITensorMPS/test/base/test_deprecated.jl new file mode 100644 index 0000000000..cfc48ec32c --- /dev/null +++ b/src/lib/ITensorMPS/test/base/test_deprecated.jl @@ -0,0 +1,27 @@ +@eval module $(gensym()) +using ITensors.ITensorMPS: MPS, maxlinkdim, randomMPS, siteinds +using LinearAlgebra: norm +using Test: @test, @testset +@testset "randomMPS" begin + sites = siteinds("S=1/2", 4) + state = j -> isodd(j) ? "↑" : "↓" + linkdims = 2 + # Deprecated linkdims syntax + for mps in [ + randomMPS(Float64, sites, state; linkdims), + randomMPS(Float64, sites; linkdims), + randomMPS(sites, state; linkdims), + randomMPS(sites, linkdims), + # Deprecated linkdims syntax + randomMPS(Float64, sites, state, linkdims), + randomMPS(Float64, sites, linkdims), + randomMPS(sites, state, linkdims), + randomMPS(sites, linkdims), + ] + @test mps isa MPS + @test length(mps) == 4 + @test maxlinkdim(mps) == 2 + @test norm(mps) > 0 + end +end +end