Skip to content

Commit

Permalink
added unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nwlandry committed Feb 20, 2024
1 parent 7d3b5aa commit 9e0fcfe
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions tests/drawing/test_draw.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ def test_draw_multilayer(edgelist8):
# node_size
assert np.all(node_coll4.get_sizes() == np.array([10**2]))

plt.close()
plt.close("all")


def test_draw_dihypergraph(diedgelist2, edgelist8):
Expand Down Expand Up @@ -587,16 +587,14 @@ def test_draw_dihypergraph(diedgelist2, edgelist8):
for patch in ax1.patches: # lines
assert patch.get_zorder() == 0

plt.close("all")

# test toggle for edges
fig, ax2 = plt.subplots()
ax2, collections = xgi.draw_dihypergraph(DH, edge_marker_toggle=False, ax=ax2)
node_coll, phantom_node_coll = collections
assert len(ax2.collections) == 1
assert phantom_node_coll is None

plt.close()
plt.close("all")

# test XGI ERROR raise
with pytest.raises(XGIError):
Expand All @@ -622,3 +620,18 @@ def test_draw_dihypergraph_with_str_labels_and_isolated_nodes():
assert len(node_coll4.get_offsets()) == 6 # number of original nodes
assert len(phantom_node_coll4.get_offsets()) == 2 # number of original edges
assert len(ax4.patches) == 7 # number of lines
plt.close()


def test_issue_499(edgelist8):
H = xgi.Hypergraph(edgelist8)

fig, ax = plt.subplots()
with pytest.warns(None) as record:
ax, collections = xgi.draw(H, ax=ax, node_fc="black")
assert len(record) == 0

with pytest.warns(None) as record:
ax, collections = xgi.draw(H, ax=ax, node_fc=["black"] * H.num_nodes)
assert len(record) == 0
plt.close("all")

0 comments on commit 9e0fcfe

Please sign in to comment.