Skip to content

Commit f6dde4c

Browse files
committed
Better error check
1 parent 516f8e8 commit f6dde4c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/abstractitensornetwork.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ function gauge_edge(
603603
# # TODO: Implement as `only(common_neighbors(tn, src(edge), dst(edge)))`
604604
# new_vertex = only(neighbors(tn, src(edge)) ∩ neighbors(tn, dst(edge)))
605605
# return contract(tn, new_vertex => dst(edge))
606-
@assert src(edge) neighbors(tn, dst(edge))
606+
!has_edge(tn, edge) && throw(ArgumentError("Edge not in graph."))
607607
tn = copy(tn)
608608
left_inds = uniqueinds(tn, edge)
609609
ltags = tags(tn, edge)
@@ -678,7 +678,7 @@ end
678678

679679
# TODO: decide whether to use graph mutating methods when resulting graph is unchanged?
680680
function _truncate_edge(tn::AbstractITensorNetwork, edge::AbstractEdge; kwargs...)
681-
@assert src(edge) neighbors(tn, dst(edge))
681+
!has_edge(tn, edge) && throw(ArgumentError("Edge not in graph."))
682682
tn = copy(tn)
683683
left_inds = uniqueinds(tn, edge)
684684
ltags = tags(tn, edge)

0 commit comments

Comments
 (0)