Skip to content

Commit 9e1e9af

Browse files
committed
tests: added one
1 parent d45add9 commit 9e1e9af

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

tests/core/test_hypergraph.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,3 +1000,27 @@ def test_cleanup():
10001000
assert cleanH["name"] == "test"
10011001

10021002
assert cleanH._edge == xgi.dual_dict(cleanH._node)
1003+
1004+
1005+
def test_fix_720():
1006+
# idx=0 must be treated as a valid user-provided ID, not as "no ID given"
1007+
1008+
# Hypergraph.add_edge: counter must advance past 0 so the next auto-ID doesn't collide
1009+
H = xgi.Hypergraph()
1010+
H.add_edge([1, 2], idx=0)
1011+
H.add_edge([2, 3])
1012+
assert H.edges.members(dtype=dict) == {0: {1, 2}, 1: {2, 3}}
1013+
1014+
# DiHypergraph.add_edge: same check for directed hypergraphs
1015+
D = xgi.DiHypergraph()
1016+
D.add_edge(([1], [2]), idx=0)
1017+
D.add_edge(([2], [3]))
1018+
assert D.edges.members(dtype=dict) == {0: {1, 2}, 1: {2, 3}}
1019+
1020+
# SimplicialComplex.add_simplex: idx=0 must not be replaced by an auto-generated ID.
1021+
# Use idx=3 first to advance the counter past 0; without the fix, the subsequent
1022+
# add_simplex with idx=0 would silently use the counter value instead.
1023+
S = xgi.SimplicialComplex()
1024+
S.add_simplex([1, 2], idx=3)
1025+
S.add_simplex([3, 4], idx=0)
1026+
assert S.edges.members(dtype=dict)[0] == {3, 4}

0 commit comments

Comments
 (0)