Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

chordSymbolFigureFromChord fails to identify RomanNumeral with sus4 or 7sus4 figures (missing 5th)

Aperta
#1,866 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
58/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
python
Ambito
backend

Direzione di ricerca

Start with the reproduction in the issue, which calls chordSymbolFigureFromChord on a RomanNumeral built from II7sus4. The compare() helper and CHORD_TYPES in music21/harmony.py decide whether a pitch set without the fifth matches the 7sus templates, and _parseFigure in music21/roman.py shows how the shorthand is expanded. Done means the repro returns a G#7sus-style figure, with the tests in the harmony module still passing; whether a missing fifth should be allowed is a maintainer decision to check first.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

music21 version

9.9.1

Operating System(s) checked
macOS, Linux

Problem summary
chordSymbolFigureFromChord() fails to identify RomanNumeral chords constructed with sus4 or 7sus4 figures (e.g., II7sus4). The function returns Chord Symbol Cannot Be Identified.

This happens because the RomanNumeral parser generates figured bass shorthand that omits the perfect 5th (e.g., 7sus4 resolves to intervals [7, 4]). When this incomplete pitch collection is passed to chordSymbolFigureFromChord(), the internal dictionary matching strictly requires the 5th to be present for any standard suspended or dominant suspended chord templates, causing the match to fail.

Steps to reproduce

import music21

# Create a 7sus4 roman numeral
rn = music21.roman.RomanNumeral("II7sus4", "F#")

# Attempt to extract its chord symbol figure
chord_figure = music21.harmony.chordSymbolFigureFromChord(rn)
print(f"Chord figure: {chord_figure}")
print(f"Pitches present: {[p.name for p in rn.pitches]}")

Expected vs. actual behavior
Expected behavior: chordSymbolFigureFromChord should return G#7sus (or similar) recognizing the suspended dominant chord.

Actual behavior:

Chord figure: Chord Symbol Cannot Be Identified
Pitches present: ['G#', 'C#', 'F#']

More information
The issue stems from a combination of how the RomanNumeral sets up pitches and how chordSymbolFigureFromChord evaluates them.

  1. Omitted Fifth in Figured Bass Resolution: In music21.roman._parseFigure, expandShortHand is called to expand 7sus4 to ['7', '4']. Because the 5th is not explicit, rn.pitches correctly omits the 5th, yielding only the Root, P4, and m7 ['G#', 'C#', 'F#'].
  2. Strict Root Forcing: Because it is a RomanNumeral, the root is strictly forced (e.g. <music21.pitch.Pitch G#4>).
  3. Failure in harmony.py: In music21/harmony.py within chordSymbolFigureFromChord, the compare() helper function iterates through CHORD_TYPES. The notation string for a standard suspended 7th requires the 5th to be present, and it is not explicitly marked as a permitted omission for this chord type. Because the 5th is missing, compare returns False for the 7sus templates, eventually falling back to Chord Symbol Cannot Be Identified.

Attempted Workarounds
Manually injecting the perfect 5th into the roman numeral before passing it to the analyzer allows it to match correctly:

rn = music21.roman.RomanNumeral("II7sus4", "F#")
rn.add("D#5")  # Explicitly add the missing P5
print(music21.harmony.chordSymbolFigureFromChord(rn))
# Output: 'G#7sus'
Lingua principale
Python
Stelle
2.6k
Fork
459
Merge medio
1g 7h
PR unite (30g)
40

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di cuthbertLab/music21

Tutte le issue di cuthbertLab/music21

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.