Skip to content

Commit

Permalink
style: black
Browse files Browse the repository at this point in the history
  • Loading branch information
maximelucas committed Oct 16, 2023
1 parent 29df5a3 commit 6d0a229
Showing 1 changed file with 28 additions and 22 deletions.
50 changes: 28 additions & 22 deletions tests/drawing/test_draw.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ def test_draw(edgelist8):

plt.close()

# simplicial complex
# simplicial complex
S = xgi.SimplicialComplex(edgelist8)

fig, ax = plt.subplots()
ax, collections = xgi.draw(S, ax=ax)
(node_collection, dyad_collection, edge_collection) = collections

# number of elements
assert len(ax.lines) == 0
assert len(ax.patches) == 0
assert len(ax.lines) == 0
assert len(ax.patches) == 0
offsets = node_collection.get_offsets()
assert offsets.shape[0] == S.num_nodes # nodes
assert len(ax.collections) == 3
assert len(ax.collections) == 3

assert len(dyad_collection.get_paths()) == 16 # dyads
assert len(edge_collection.get_paths()) == 3 # other hyperedges
Expand Down Expand Up @@ -232,7 +232,9 @@ def test_draw_hyperedges(edgelist8):
ax, collections = xgi.draw_hyperedges(H, ax=ax)
(dyad_collection, edge_collection) = collections
fig2, ax2 = plt.subplots()
ax2, collections2 = xgi.draw_hyperedges(H, ax=ax2, dyad_color="r", edge_fc="r", dyad_lw=3, dyad_style="--")
ax2, collections2 = xgi.draw_hyperedges(
H, ax=ax2, dyad_color="r", edge_fc="r", dyad_lw=3, dyad_style="--"
)
(dyad_collection2, edge_collection2) = collections2

# number of elements
Expand All @@ -253,33 +255,27 @@ def test_draw_hyperedges(edgelist8):
dyad_collection2.get_linestyle() == [(0.0, [5.550000000000001, 2.4000000000000004])]

# dyad_fc
assert np.all(
dyad_collection.get_color() == np.array([[0, 0, 0, 1]])
) # black
assert np.all(
dyad_collection2.get_color() == np.array([[1, 0, 0, 1]])
) # black
assert np.all(dyad_collection.get_color() == np.array([[0, 0, 0, 1]])) # black
assert np.all(dyad_collection2.get_color() == np.array([[1, 0, 0, 1]])) # black

# edge_fc
assert np.all(
edge_collection.get_facecolor()[:, -1] == np.array([0.4, 0.4, 0.4, 0.4, 0.4, 0.4])
)
assert np.all(
edge_collection2.get_facecolor() == np.array([[1., 0., 0., 0.4]])
edge_collection.get_facecolor()[:, -1]
== np.array([0.4, 0.4, 0.4, 0.4, 0.4, 0.4])
)
assert np.all(edge_collection2.get_facecolor() == np.array([[1.0, 0.0, 0.0, 0.4]]))

# edge_lw
assert np.all(dyad_collection.get_linewidth() == np.array([1.5]))
assert np.all(dyad_collection2.get_linewidth() == np.array([3]))
assert np.all(edge_collection.get_linewidth() == np.array([1.]))
assert np.all(edge_collection.get_linewidth() == np.array([1.0]))

# negative node_lw or node_size
with pytest.raises(ValueError):
ax, collections = xgi.draw_hyperedges(H, ax=ax, dyad_lw=-1)
(dyad_collection, edge_collection) = collections
plt.close()


plt.close("all")


Expand All @@ -298,7 +294,9 @@ def test_draw_hyperedges_fc_cmap(edgelist8):
# set cmap
fig, ax = plt.subplots()
dyad_colors = [1, 3, 5]
ax, collections = xgi.draw_hyperedges(H, ax=ax, dyad_color=dyad_colors, dyad_color_cmap="Greens", edge_fc_cmap="Blues")
ax, collections = xgi.draw_hyperedges(
H, ax=ax, dyad_color=dyad_colors, dyad_color_cmap="Greens", edge_fc_cmap="Blues"
)
(dyad_collection, edge_collection) = collections
assert dyad_collection.get_cmap() == plt.cm.Greens
assert edge_collection.get_cmap() == plt.cm.Blues
Expand All @@ -312,7 +310,15 @@ def test_draw_hyperedges_fc_cmap(edgelist8):

# vmin/vmax
fig, ax = plt.subplots()
ax, collections = xgi.draw_hyperedges(H, ax=ax, dyad_color=dyad_colors, dyad_vmin=5, dyad_vmax=6, edge_vmin=14, edge_vmax=19)
ax, collections = xgi.draw_hyperedges(
H,
ax=ax,
dyad_color=dyad_colors,
dyad_vmin=5,
dyad_vmax=6,
edge_vmin=14,
edge_vmax=19,
)
(dyad_collection, edge_collection) = collections
plt.colorbar(dyad_collection)
plt.colorbar(edge_collection)
Expand All @@ -335,9 +341,9 @@ def test_draw_simplices(edgelist8):
(dyad_collection, edge_collection) = collections

# number of elements
assert len(ax.lines) == 0
assert len(ax.patches) == 0
assert len(ax.collections) == 2
assert len(ax.lines) == 0
assert len(ax.patches) == 0
assert len(ax.collections) == 2

assert len(dyad_collection.get_paths()) == 16 # dyads
assert len(edge_collection.get_paths()) == 3 # other hyperedges
Expand Down

0 comments on commit 6d0a229

Please sign in to comment.