Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/abstractitensornetwork.jl
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ function linkdim(tn::AbstractITensorNetwork, edge::Pair)
return linkdim(tn, edgetype(tn)(edge))
end

function linkdim(tn::AbstractITensorNetwork{V}, edge::AbstractEdge{V}) where {V}
function linkdim(tn::AbstractITensorNetwork, edge::AbstractEdge)
ls = linkinds(tn, edge)
return prod([isnothing(l) ? 1 : dim(l) for l in ls])
end
Expand Down
12 changes: 12 additions & 0 deletions test/test_itensornetwork.jl
Original file line number Diff line number Diff line change
Expand Up @@ -250,4 +250,16 @@ const elts = (Float32, Float64, Complex{Float32}, Complex{Float64})
tn = random_tensornetwork(rng, is; link_space = 3)
@test_broken swapprime(tn, 0, 2)
end

# Regression test for https://github.com/ITensor/ITensorNetworks.jl/pull/373.
@testset "linkdim accepts an AbstractEdge whose vertex type is a subtype" begin
i = Index(2)
A = ITensor(i)
B = ITensor(i)
tn = ITensorNetwork{Any}(Dictionary([1, 2], [A, B]))
@test tn isa ITensorNetwork{Any}
e = NamedEdge(1 => 2)
@test e isa NamedEdge{Int}
@test ITensorNetworks.linkdim(tn, e) == 2
end
end
Loading