|
4 | 4 | from xgi.exception import IDNotFound, XGIError |
5 | 5 |
|
6 | 6 |
|
| 7 | +def test_equality(edgelist1, edgelist2, diedgelist1, diedgelist2): |
| 8 | + # hypergraph |
| 9 | + H1 = xgi.Hypergraph(edgelist1) |
| 10 | + H2 = xgi.Hypergraph(edgelist1) |
| 11 | + H3 = xgi.Hypergraph(edgelist2) |
| 12 | + |
| 13 | + assert xgi.equal(H1, H2) |
| 14 | + assert not xgi.equal(H2, H3) |
| 15 | + |
| 16 | + H1["test"] = "this should break equality" |
| 17 | + assert not xgi.equal(H1, H2) |
| 18 | + |
| 19 | + assert xgi.equal(H1, H2, compare_attrs=False) |
| 20 | + |
| 21 | + el1 = {0: {1, 2, 3}, 1: {1, 2}} |
| 22 | + el2 = {1: {1, 2, 3}, 2: {1, 2}} |
| 23 | + |
| 24 | + H1 = xgi.Hypergraph(el1) |
| 25 | + H2 = xgi.Hypergraph(el2) |
| 26 | + |
| 27 | + assert not xgi.equal(H1, H2, compare_ids=True) |
| 28 | + assert xgi.equal(H1, H2, compare_ids=False) |
| 29 | + |
| 30 | + # dihypergraphs |
| 31 | + H1 = xgi.DiHypergraph(diedgelist1) |
| 32 | + H2 = xgi.DiHypergraph(diedgelist1) |
| 33 | + H3 = xgi.DiHypergraph(diedgelist2) |
| 34 | + |
| 35 | + assert xgi.equal(H1, H2) |
| 36 | + assert not xgi.equal(H2, H3) |
| 37 | + |
| 38 | + H1["test"] = "this should break equality" |
| 39 | + assert not xgi.equal(H1, H2) |
| 40 | + |
| 41 | + assert xgi.equal(H1, H2, compare_attrs=False) |
| 42 | + |
| 43 | + del1 = {0: ({1, 2, 3}, {4}), 1: ({5, 6}, {6, 7, 8})} |
| 44 | + del2 = {1: ({1, 2, 3}, {4}), 2: ({5, 6}, {6, 7, 8})} |
| 45 | + |
| 46 | + H1 = xgi.DiHypergraph(del1) |
| 47 | + H2 = xgi.DiHypergraph(del2) |
| 48 | + |
| 49 | + assert not xgi.equal(H1, H2, compare_ids=True) |
| 50 | + assert xgi.equal(H1, H2, compare_ids=False) |
| 51 | + |
| 52 | + |
7 | 53 | def test_num_edges_order(edgelist2): |
8 | 54 | H = xgi.Hypergraph(edgelist2) |
9 | 55 |
|
|
0 commit comments