-
Notifications
You must be signed in to change notification settings - Fork 13
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
Improve compatibility with tensor networks without internal vertices #144
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -798,7 +798,11 @@ function hascommoninds( | |
::typeof(siteinds), A::AbstractITensorNetwork{V}, B::AbstractITensorNetwork{V} | ||
) where {V} | ||
for v in vertices(A) | ||
!hascommoninds(siteinds(A, v), siteinds(B, v)) && return false | ||
if isempty(siteinds(A, v)) | ||
!isempty(siteinds(B, v)) && return false | ||
else | ||
!hascommoninds(siteinds(A, v), siteinds(B, v)) && return false | ||
end | ||
Comment on lines
+801
to
+805
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm confused by this change. It seems like this catches the case when There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Gotcha, thanks. I see that is a strange corner case. See my comment #144 (comment), I think it would be simpler to just remove these functions entirely, since they are likely doing more harm than good, and we can reassess what kind of checks we really want in this functions, if any. |
||
end | ||
return true | ||
end | ||
|
@@ -815,9 +819,15 @@ function check_hascommoninds( | |
) | ||
end | ||
for v in vertices(A) | ||
!hascommoninds(siteinds(A, v), siteinds(B, v)) && error( | ||
"$(typeof(A)) A and $(typeof(B)) B must share site indices. On vertex $v, A has site indices $(siteinds(A, v)) while B has site indices $(siteinds(B, v)).", | ||
) | ||
if isempty(siteinds(A, v)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. |
||
!(isempty(siteinds(B, v))) && error( | ||
"$(typeof(A)) A and $(typeof(B)) B must share site indices. On vertex $v, A has no site indices while B has site indices $(siteinds(B, v)).", | ||
) | ||
else | ||
!hascommoninds(siteinds(A, v), siteinds(B, v)) && error( | ||
"$(typeof(A)) A and $(typeof(B)) B must share site indices. On vertex $v, A has site indices $(siteinds(A, v)) while B has site indices $(siteinds(B, v)).", | ||
) | ||
end | ||
end | ||
return nothing | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -247,7 +247,6 @@ end | |
Tttno = contract(Hsvd) | ||
end | ||
@test Tttno ≈ Tmpo rtol = 1e-6 | ||
|
||
Hsvd_lr = TTN( | ||
Hlr, is_missing_site; root_vertex=root_vertex, algorithm="svd", cutoff=1e-10 | ||
) | ||
|
@@ -257,6 +256,10 @@ end | |
Tmpo_lr = contract(Hsvd_lr) | ||
end | ||
@test Tttno_lr ≈ Tmpo_lr rtol = 1e-6 | ||
# ToDo: move to a more appropriate file, since this is not related to OpSum to TTN conversion | ||
# test whether Hamiltonian contracts with itself (used to error due to missing siteindices) | ||
@test isa(inner(Hsvd, Hsvd), Number) | ||
Comment on lines
+259
to
+261
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. Also, it would be good to add tests for |
||
end | ||
end | ||
end | ||
return nothing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for
check_hascommoninds
.