Skip to content

Commit

Permalink
response to review
Browse files Browse the repository at this point in the history
  • Loading branch information
nwlandry committed Nov 24, 2024
1 parent 229e14f commit ab5364c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions tests/readwrite/test_bipartite_edgelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ def test_read_bipartite_edgelist(file_string, extra_kwargs):

H = xgi.read_bipartite_edgelist(filename, nodetype=int, **extra_kwargs)
int_edgelist = [{0, 1, 2, 3}, {4}, {5, 6}, {6, 7, 8}]
assert [H.edges.members(e) for e in H.edges] == int_edgelist
assert [H.edges.members(eid) for eid in H.edges] == int_edgelist
H = xgi.read_bipartite_edgelist(filename, nodetype=str, **extra_kwargs)
str_edgelist = [{"0", "1", "2", "3"}, {"4"}, {"5", "6"}, {"6", "7", "8"}]
assert [H.edges.members(e) for e in H.edges] == str_edgelist
assert [H.edges.members(eid) for eid in H.edges] == str_edgelist


def test_parse_bipartite_edgelist():
Expand Down Expand Up @@ -93,14 +93,14 @@ def test_parse_bipartite_edgelist():
assert list(H.nodes) == [0, 1, 2, 3, 4, 5, 6, 7, 8]
assert list(H.edges) == [0, 1, 2, 3]
edges = [{0, 1, 2, 3}, {4}, {5, 6}, {6, 7, 8}]
assert [H.edges.members(e) for e in H.edges] == edges
assert [H.edges.members(eid) for eid in H.edges] == edges

H = xgi.parse_bipartite_edgelist(lines, nodetype=int, edgetype=int, dual=True)
assert list(H.nodes) == [0, 1, 2, 3]
assert list(H.edges) == [0, 1, 2, 3, 4, 5, 6, 7, 8]
print([H.edges.members(e) for e in H.edges])
print([H.edges.members(eid) for eid in H.edges])
edges = [{0}, {0}, {0}, {0}, {1}, {2}, {2, 3}, {3}, {3}]
assert [H.edges.members(e) for e in H.edges] == edges
assert [H.edges.members(eid) for eid in H.edges] == edges

# test less than two entries per line
with pytest.raises(XGIError):
Expand Down
6 changes: 3 additions & 3 deletions tests/readwrite/test_edgelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,18 @@ def test_read_edgelist(file_string, extra_kwargs):

H = xgi.read_edgelist(filename, nodetype=int, **extra_kwargs)
int_edgelist = [{1, 2}, {2, 3, 4}, {1, 4, 7, 8}, {2, 3}]
assert [H.edges.members(e) for e in H.edges] == int_edgelist
assert [H.edges.members(eid) for eid in H.edges] == int_edgelist
H = xgi.read_edgelist(filename, nodetype=str, **extra_kwargs)
str_edgelist = [{"1", "2"}, {"2", "3", "4"}, {"1", "4", "7", "8"}, {"2", "3"}]
assert [H.edges.members(e) for e in H.edges] == str_edgelist
assert [H.edges.members(eid) for eid in H.edges] == str_edgelist


def test_parse_edgelist():
H = xgi.parse_edgelist(["1 2", "2 3 4", "1 4 7 8", "2 3"], nodetype=int)
assert set(H.nodes) == {1, 2, 3, 4, 7, 8}
assert set(H.edges) == {0, 1, 2, 3}
edges = [{1, 2}, {2, 3, 4}, {1, 4, 7, 8}, {2, 3}]
assert [H.edges.members(e) for e in H.edges] == edges
assert [H.edges.members(eid) for eid in H.edges] == edges

# This will fail because the "test" node ID can't be converted to int
with pytest.raises(TypeError):
Expand Down
2 changes: 1 addition & 1 deletion tests/readwrite/test_incidence_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def test_read_incidence_matrix(file_string, extra_kwargs):

H = xgi.read_incidence_matrix(filename, **extra_kwargs)
int_edgelist = [{0, 1, 2, 3}, {4}, {5, 6}, {6, 7, 8}]
assert [H.edges.members(e) for e in H.edges] == int_edgelist
assert [H.edges.members(eid) for eid in H.edges] == int_edgelist


def test_write_incidence_matrix(edgelist5):
Expand Down

0 comments on commit ab5364c

Please sign in to comment.