Skip to content

Commit

Permalink
Merge branch 'main' into refactor_expect_simplified
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeyT1994 authored May 2, 2024
2 parents a498736 + 286a048 commit b350e4d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ITensorNetworks"
uuid = "2919e153-833c-4bdc-8836-1ea460a35fc7"
authors = ["Matthew Fishman <[email protected]>, Joseph Tindall <[email protected]> and contributors"]
version = "0.10.0"
version = "0.10.2"

[deps]
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
Expand Down
16 changes: 15 additions & 1 deletion src/treetensornetworks/projttns/projttn.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,24 @@ struct ProjTTN{V,Pos<:Union{Indices{V},NamedEdge{V}}} <: AbstractProjTTN{V}
pos::Pos
operator::TTN{V}
environments::Dictionary{NamedEdge{V},ITensor}
global function _ProjTTN(pos, operator::TTN, environments::Dictionary)
return new{vertextype(operator),Indices{vertextype(operator)}}(
Indices{vertextype(operator)}(pos),
operator,
convert(Dictionary{NamedEdge{vertextype(operator)},ITensor}, environments),
)
end
global function _ProjTTN(pos::NamedEdge, operator::TTN, environments::Dictionary)
return new{vertextype(operator),NamedEdge{vertextype(operator)}}(
convert(NamedEdge{vertextype(operator)}, pos),
operator,
convert(Dictionary{NamedEdge{vertextype(operator)},ITensor}, environments),
)
end
end

function ProjTTN(pos, operator::TTN, environments::Dictionary)
return ProjTTN(Indices(pos), operator, environments)
return _ProjTTN(pos, operator, environments)
end

function ProjTTN(operator::TTN)
Expand Down
2 changes: 2 additions & 0 deletions test/test_treetensornetworks/Project.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
[deps]
Dictionaries = "85a47980-9c8c-11e8-2b9f-f7ca1fa99fb4"
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
ITensorNetworks = "2919e153-833c-4bdc-8836-1ea460a35fc7"
ITensors = "9136182c-28ba-11e9-034c-db9fb085ebd5"
NamedGraphs = "678767b0-92e7-4007-89e4-4527a8725b19"
15 changes: 12 additions & 3 deletions test/test_treetensornetworks/test_position.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
@eval module $(gensym())
using Dictionaries: Dictionary, Indices
using Graphs: vertices
using ITensors: ITensors
using ITensorNetworks: ProjTTN, ttn, environments, position, siteinds
using ITensors: ITensors, ITensor
using ITensorNetworks: ITensorNetwork, ProjTTN, ttn, environments, position, siteinds
using ITensorNetworks.ModelHamiltonians: ModelHamiltonians
using NamedGraphs.NamedGraphGenerators: named_comb_tree
using NamedGraphs: NamedEdge
using NamedGraphs.NamedGraphGenerators: named_comb_tree, named_path_graph
using Test: @test, @testset

@testset "ProjTTN position" begin
Expand Down Expand Up @@ -47,4 +49,11 @@ using Test: @test, @testset
ITensors.disable_auto_fermion()
end
end
@testset "ProjTTN construction regression test" begin
pos = Indices{Tuple{String,Int}}()
g = named_path_graph(2)
operator = ttn(ITensorNetwork{Any}(g))
environments = Dictionary{NamedEdge{Any},ITensor}()
@test ProjTTN(pos, operator, environments) isa ProjTTN{Any,Indices{Any}}
end
end

0 comments on commit b350e4d

Please sign in to comment.