Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ITensorMPS] Fix some lingering namespace issues #1362

Merged
merged 6 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ITensorGaussianMPS/src/gmps.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Base: sortperm, size, length, eltype, conj, transpose, copy, *
using ITensors: alias
using ITensors: alias, ITensorMPS
emstoudenmire marked this conversation as resolved.
Show resolved Hide resolved
abstract type AbstractSymmetry end
struct ConservesNfParity{T} <: AbstractSymmetry
data::T
Expand Down Expand Up @@ -177,8 +177,8 @@ end

function quadratic_operator(os::OpSum)
os = deepcopy(os)
#os = ITensors.sorteachterm(os, sites)
os = ITensors.sortmergeterms(os)
#os = ITensorMPS.sorteachterm(os, sites)
os = ITensorMPS.sortmergeterms(os)

nterms = length(os)
coefs = Vector{Number}(undef, nterms)
Expand Down
6 changes: 3 additions & 3 deletions src/ITensorMPS/abstractprojmpo/projmposum.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ end
copy(P::AbstractSum) = typeof(P)(copy.(terms(P)))

function nsite(P::AbstractSum)
@assert allequal(nsite.(terms(P)))
@assert all(y -> y == nsite(first(terms(P))), nsite.(terms(P)))
return nsite(first(terms(P)))
end

Expand All @@ -19,12 +19,12 @@ function set_nsite!(A::AbstractSum, nsite)
end

function length(A::AbstractSum)
@assert allequal(length.(terms(A)))
@assert all(y -> y == length(first(terms(A))), length.(terms(A)))
return length(first(terms(A)))
end

function site_range(A::AbstractSum)
@assert allequal(Iterators.map(site_range, terms(A)))
@assert all(y -> y == site_range(first(terms(A))), Iterators.map(site_range, terms(A)))
return site_range(first(terms(A)))
end

Expand Down
7 changes: 3 additions & 4 deletions src/ITensorMPS/dmrg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,11 @@ function dmrg(
## into `DeviceMemory`. This conversion line is here temporarily to fix that problem when it arises
## Adapt is only called when using CUDA backend. CPU will work as implemented previously.
## TODO this might be the only place we really need iscu if its not fixed.
phi::ITensor = if NDTensors.iscu(phi) && NDTensors.iscu(vecs[1])
adapt(set_eltype(unwrap_array_type(phi), eltype(vecs[1])), vecs[1])
if NDTensors.iscu(phi) && NDTensors.iscu(vecs[1])
phi = adapt(ITensors.set_eltype(unwrap_array_type(phi), eltype(vecs[1])), vecs[1])
else
vecs[1]
phi = vecs[1]
end
emstoudenmire marked this conversation as resolved.
Show resolved Hide resolved
#phi::ITensor = vecs[1]

ortho = ha == 1 ? "left" : "right"

Expand Down
3 changes: 2 additions & 1 deletion test/ITensorMPS/Ops/test_ops_mpo.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Test
using ITensors
using ITensors.Ops
using ITensors: ITensorMPS
emstoudenmire marked this conversation as resolved.
Show resolved Hide resolved
using LinearAlgebra

@testset "Ops to MPO" begin
Expand Down Expand Up @@ -42,7 +43,7 @@ using LinearAlgebra
ℋ_merged = OpSum()
ℋ_merged += (4, "Z", 1)
ℋ_merged += (3, "X", 2)
@test ITensors.sortmergeterms(ℋ) == ℋ_merged
@test ITensorMPS.sortmergeterms(ℋ) == ℋ_merged

# Test with repeated terms
s = siteinds("S=1/2", 1)
Expand Down
Loading