Skip to content

Commit

Permalink
Fix externalinds, add tests for externalinds and internalinds (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeyT1994 authored Jan 12, 2024
1 parent 0b72b7c commit 9a75be2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/abstractitensornetwork.jl
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ function internalinds(tn::AbstractITensorNetwork)
end

function externalinds(tn::AbstractITensorNetwork)
return unique(flatten([uniqueinds(tn, e) for e in edges(tn)]))
return unique(flatten([uniqueinds(tn, v) for v in vertices(tn)]))
end

# Priming and tagging (changing Index identifiers)
Expand Down
2 changes: 2 additions & 0 deletions src/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ export AbstractITensorNetwork,
norm_sqr_network,
linkinds_combiners,
combine_linkinds,
externalinds,
internalinds,
subgraphs,
reverse_bfs_edges,
randomITensorNetwork,
Expand Down
3 changes: 3 additions & 0 deletions test/test_itensornetwork.jl
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@ using Test
@test isempty(commoninds(uie, cie))

@test linkinds(ψ, e) == commoninds(ψ[1, 1], ψ[2, 1])

@test length(externalinds(ψ)) == length(vertices(g))
@test length(internalinds(ψ)) == length(edges(g))
end

@testset "ElType conversion, $new_eltype" for new_eltype in (Float32, ComplexF64)
Expand Down

0 comments on commit 9a75be2

Please sign in to comment.