Skip to content

musical score layout hooks#1869

Open
mpharrigan wants to merge 1 commit into
quantumlib:mainfrom
mpharrigan:2026-06/musical-score-more
Open

musical score layout hooks#1869
mpharrigan wants to merge 1 commit into
quantumlib:mainfrom
mpharrigan:2026-06/musical-score-more

Conversation

@mpharrigan

Copy link
Copy Markdown
Collaborator
  • factor out steps for building MusicalScoreData so you can control the drawn order of lines
  • styling improvements
  • play nicely with plt and accept optional ax parameter

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the musical score layout logic by introducing the _MusicalScoreLayoutBuilder class to handle horizontal and vertical layouts, and the BinstLabeller class to customize labels and symbols. It also introduces custom pentagon box styles for matplotlib, updates various wire symbols (such as TextBox and ModPlus), and allows draw_musical_score to accept an external matplotlib axis. Additionally, _soq_to_symb is moved to qpic_diagram.py. A critical issue was identified in ModPlus.draw where plt.Line2D is used, which will raise an AttributeError at runtime since Line2D resides in matplotlib.lines rather than matplotlib.pyplot.

Comment on lines +827 to +828
line1 = plt.Line2D([-radius_px, radius_px], [0, 0], color='k', lw=lw, transform=xform)
line2 = plt.Line2D([0, 0], [-radius_px, radius_px], color='k', lw=lw, transform=xform)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

Using plt.Line2D will raise an AttributeError at runtime because matplotlib.pyplot (imported as plt) does not expose the Line2D class. Line2D is located in the matplotlib.lines module. Please import and use matplotlib.lines.Line2D instead.

Suggested change
line1 = plt.Line2D([-radius_px, radius_px], [0, 0], color='k', lw=lw, transform=xform)
line2 = plt.Line2D([0, 0], [-radius_px, radius_px], color='k', lw=lw, transform=xform)
import matplotlib.lines as mlines
line1 = mlines.Line2D([-radius_px, radius_px], [0, 0], color='k', lw=lw, transform=xform)
line2 = mlines.Line2D([0, 0], [-radius_px, radius_px], color='k', lw=lw, transform=xform)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant