Skip to content

Commit

Permalink
style: black
Browse files Browse the repository at this point in the history
  • Loading branch information
maximelucas committed Sep 1, 2024
1 parent 42c52a5 commit 610f9c9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
7 changes: 4 additions & 3 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,10 @@
# further. For a list of options available for each theme, see the
# documentation.
html_theme_options = {
"navbar_end": ["theme-switcher", "navbar-icon-links"], # Place the social links at the end of the navbar
"navbar_end": [
"theme-switcher",
"navbar-icon-links",
], # Place the social links at the end of the navbar
"icon_links": [
{
"name": "GitHub",
Expand All @@ -181,8 +184,6 @@
}




html_sidebars = {
"**": ["sidebar-nav-bs", "sidebar-ethical-ads"],
"index": [],
Expand Down
18 changes: 11 additions & 7 deletions tests/drawing/test_draw.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,16 +340,20 @@ def test_draw_hyperedges_ec(edgelist8):

H = xgi.Hypergraph(edgelist8)

colors = np.array([[0.6468274 , 0.80289262, 0.56592265, 0.4],
[0.17363177, 0.19076859, 0.44549087, 0.4],
[0.17363177, 0.19076859, 0.44549087, 0.4],
[0.17363177, 0.19076859, 0.44549087, 0.4],
[0.17363177, 0.19076859, 0.44549087, 0.4],
[0.17363177, 0.19076859, 0.44549087, 0.4]])
colors = np.array(
[
[0.6468274, 0.80289262, 0.56592265, 0.4],
[0.17363177, 0.19076859, 0.44549087, 0.4],
[0.17363177, 0.19076859, 0.44549087, 0.4],
[0.17363177, 0.19076859, 0.44549087, 0.4],
[0.17363177, 0.19076859, 0.44549087, 0.4],
[0.17363177, 0.19076859, 0.44549087, 0.4],
]
)

# edge stat color
fig, ax = plt.subplots()
ax, collections = xgi.draw_hyperedges(H,ax=ax, edge_ec=H.edges.size, edge_fc="w")
ax, collections = xgi.draw_hyperedges(H, ax=ax, edge_ec=H.edges.size, edge_fc="w")
(_, edge_collection) = collections

assert np.all(edge_collection.get_edgecolor() == colors)
Expand Down
13 changes: 6 additions & 7 deletions xgi/drawing/draw.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def draw(
* IDStat containing the `ids` as keys
If None (default), color by edge size.
Numerical formats will be mapped to colors using edge_vmin, edge_vmax,
Numerical formats will be mapped to colors using edge_vmin, edge_vmax,
and edge_fc_cmap.
alpha : float, optional
The edge transparency. By default, 0.4.
Expand Down Expand Up @@ -618,7 +618,7 @@ def draw_hyperedges(
* IDStat containing the `ids` as keys
If None (default), color by edge size.
Numerical formats will be mapped to colors using edge_vmin, edge_vmax,
Numerical formats will be mapped to colors using edge_vmin, edge_vmax,
and edge_fc_cmap.
alpha : float, optional
The edge transparency. By default, 0.4.
Expand Down Expand Up @@ -752,17 +752,16 @@ def draw_hyperedges(
edge_fc_arr = None
edge_fc_colors = edge_fc[ids_sorted] if len(edge_fc) > 1 else edge_fc


edge_ec = edge_ec[ids_sorted] if len(edge_ec) > 1 else edge_ec # reorder
edge_ec = edge_ec[ids_sorted] if len(edge_ec) > 1 else edge_ec # reorder

if edge_ec_to_map: # edgecolors need to be manually mapped
if edge_ec_to_map: # edgecolors need to be manually mapped

# create scalarmappable to map floats to colors
# we use the same vmin, vmax, and cmap as for edge_fc
norm = mpl.colors.Normalize(vmin=edge_vmin, vmax=edge_vmax)
sm_edgecolors = cm.ScalarMappable(norm=norm, cmap=edge_fc_cmap)

edge_ec = sm_edgecolors.to_rgba(edge_ec) # map to colors
edge_ec = sm_edgecolors.to_rgba(edge_ec) # map to colors

patches = []
for he in np.array(edges.members())[ids_sorted]:
Expand Down Expand Up @@ -790,7 +789,7 @@ def draw_hyperedges(
edge_collection = PatchCollection(
patches,
facecolors=edge_fc_colors,
array=edge_fc_arr, # will be mapped by PatchCollection
array=edge_fc_arr, # will be mapped by PatchCollection
cmap=edge_fc_cmap,
edgecolors=edge_ec,
alpha=alpha,
Expand Down

0 comments on commit 610f9c9

Please sign in to comment.