Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン
#1,866 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
58/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
静か
技術スタック
python
領域
backend

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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'
主要言語
Python
スター
2.6k
フォーク
459
平均マージ
1日 7時間
マージ済み PR(30日)
40

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

cuthbertLab/music21 のほかの issue

cuthbertLab/music21 の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。