Skip to content

Commit

Permalink
Fix bug where edge colors are randomly shuffled in mpl_draw (#1312)
Browse files Browse the repository at this point in the history
* Try to make edge_pos iteration deterministic

* Fix minor bug

* Add release note

(cherry picked from commit 44d9fb0)

# Conflicts:
#	rustworkx/visualization/matplotlib.py
  • Loading branch information
IvanIsCoding authored and mergify[bot] committed Nov 16, 2024
1 parent 98176b6 commit 602046f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions releasenotes/notes/correct-edge-colors-e082e1761e1c060b.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
fixes:
- |
Fixed a bug introduced in version 0.15 where the edge colors specified as
a list in calls to :func:`~rustworkx.visualization.mpl_draw` were not
having their order respected. Instead, the order of the colors was
being shuffled. This has been restored and now the behavior should
match that of 0.14.
7 changes: 7 additions & 0 deletions rustworkx/visualization/matplotlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,14 @@ def draw_edges(
edge_color = "k"

# set edge positions
<<<<<<< HEAD
edge_pos = np.asarray([(pos[e[0]], pos[e[1]]) for e in edge_list])
=======
edge_pos_keys = dict()
for e in edge_list:
edge_pos_keys[(tuple(pos[e[0]]), tuple(pos[e[1]]))] = None
edge_pos = edge_pos_keys.keys()
>>>>>>> 44d9fb0 (Fix bug where edge colors are randomly shuffled in `mpl_draw` (#1312))

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

0 comments on commit 602046f

Please sign in to comment.