Skip to content

Commit 286a048

Browse files
authored
Fix ProjTTN constructor for mixed input vertex types (#165)
1 parent f0d6a6f commit 286a048

File tree

4 files changed

+30
-5
lines changed

4 files changed

+30
-5
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ITensorNetworks"
22
uuid = "2919e153-833c-4bdc-8836-1ea460a35fc7"
33
authors = ["Matthew Fishman <[email protected]> and contributors"]
4-
version = "0.10.1"
4+
version = "0.10.2"
55

66
[deps]
77
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"

src/treetensornetworks/projttns/projttn.jl

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,24 @@ struct ProjTTN{V,Pos<:Union{Indices{V},NamedEdge{V}}} <: AbstractProjTTN{V}
1212
pos::Pos
1313
operator::TTN{V}
1414
environments::Dictionary{NamedEdge{V},ITensor}
15+
global function _ProjTTN(pos, operator::TTN, environments::Dictionary)
16+
return new{vertextype(operator),Indices{vertextype(operator)}}(
17+
Indices{vertextype(operator)}(pos),
18+
operator,
19+
convert(Dictionary{NamedEdge{vertextype(operator)},ITensor}, environments),
20+
)
21+
end
22+
global function _ProjTTN(pos::NamedEdge, operator::TTN, environments::Dictionary)
23+
return new{vertextype(operator),NamedEdge{vertextype(operator)}}(
24+
convert(NamedEdge{vertextype(operator)}, pos),
25+
operator,
26+
convert(Dictionary{NamedEdge{vertextype(operator)},ITensor}, environments),
27+
)
28+
end
1529
end
1630

1731
function ProjTTN(pos, operator::TTN, environments::Dictionary)
18-
return ProjTTN(Indices(pos), operator, environments)
32+
return _ProjTTN(pos, operator, environments)
1933
end
2034

2135
function ProjTTN(operator::TTN)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
[deps]
2+
Dictionaries = "85a47980-9c8c-11e8-2b9f-f7ca1fa99fb4"
23
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
34
ITensorNetworks = "2919e153-833c-4bdc-8836-1ea460a35fc7"
5+
ITensors = "9136182c-28ba-11e9-034c-db9fb085ebd5"
46
NamedGraphs = "678767b0-92e7-4007-89e4-4527a8725b19"

test/test_treetensornetworks/test_position.jl

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
@eval module $(gensym())
2+
using Dictionaries: Dictionary, Indices
23
using Graphs: vertices
3-
using ITensors: ITensors
4-
using ITensorNetworks: ProjTTN, ttn, environments, position, siteinds
4+
using ITensors: ITensors, ITensor
5+
using ITensorNetworks: ITensorNetwork, ProjTTN, ttn, environments, position, siteinds
56
using ITensorNetworks.ModelHamiltonians: ModelHamiltonians
6-
using NamedGraphs.NamedGraphGenerators: named_comb_tree
7+
using NamedGraphs: NamedEdge
8+
using NamedGraphs.NamedGraphGenerators: named_comb_tree, named_path_graph
79
using Test: @test, @testset
810

911
@testset "ProjTTN position" begin
@@ -47,4 +49,11 @@ using Test: @test, @testset
4749
ITensors.disable_auto_fermion()
4850
end
4951
end
52+
@testset "ProjTTN construction regression test" begin
53+
pos = Indices{Tuple{String,Int}}()
54+
g = named_path_graph(2)
55+
operator = ttn(ITensorNetwork{Any}(g))
56+
environments = Dictionary{NamedEdge{Any},ITensor}()
57+
@test ProjTTN(pos, operator, environments) isa ProjTTN{Any,Indices{Any}}
58+
end
5059
end

0 commit comments

Comments
 (0)