Skip to content

Commit 44d9fb0

Browse files
authored
Fix bug where edge colors are randomly shuffled in mpl_draw (#1312)
* Try to make edge_pos iteration deterministic * Fix minor bug * Add release note
1 parent d9fbe83 commit 44d9fb0

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
fixes:
3+
- |
4+
Fixed a bug introduced in version 0.15 where the edge colors specified as
5+
a list in calls to :func:`~rustworkx.visualization.mpl_draw` were not
6+
having their order respected. Instead, the order of the colors was
7+
being shuffled. This has been restored and now the behavior should
8+
match that of 0.14.

rustworkx/visualization/matplotlib.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -636,9 +636,10 @@ def draw_edges(
636636
edge_color = "k"
637637

638638
# set edge positions
639-
edge_pos = set()
639+
edge_pos_keys = dict()
640640
for e in edge_list:
641-
edge_pos.add((tuple(pos[e[0]]), tuple(pos[e[1]])))
641+
edge_pos_keys[(tuple(pos[e[0]]), tuple(pos[e[1]]))] = None
642+
edge_pos = edge_pos_keys.keys()
642643

643644
# Check if edge_color is an array of floats and map to edge_cmap.
644645
# This is the only case handled differently from matplotlib

0 commit comments

Comments
 (0)