Skip to content

Commit

Permalink
Add back missing randomMPS constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
mtfishman committed May 16, 2024
1 parent aea2af3 commit cfdd75e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/lib/ITensorMPS/src/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
27 changes: 27 additions & 0 deletions src/lib/ITensorMPS/test/base/test_deprecated.jl
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit cfdd75e

Please sign in to comment.