Skip to content

Commit

Permalink
Fix ProjTTN constructor for mixed input vertex types (#165)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtfishman authored May 2, 2024
1 parent f0d6a6f commit 286a048
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 <mfishman@flatironinstitute.org> and contributors"]
version = "0.10.1"
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

2 comments on commit 286a048

@mtfishman
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/106014

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.10.2 -m "<description of version>" 286a048e8602219b97be7f14f289b75ba3387040
git push origin v0.10.2

Please sign in to comment.