`TypeError` in `ChordReducer.run()` on multi-part `stream.Score` without instrument `partId`s
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 62/100
Hướng nghiên cứu
Lỗi crash nằm ở TimespanTree.allParts() trong music21/tree/timespanTree.py (khoảng dòng 743), nơi các phần được sắp xếp theo getInstrument().partId, giá trị này có thể là None. Hãy bắt đầu từ ChordReducer.run() trong music21/analysis/reduceChords.py và chạy script tái hiện trong issue. Việc hoàn thành được xác định khi script chạy xong không có TypeError và các phần giữ được thứ tự hợp lý, ví dụ thứ tự chúng xuất hiện trong bản nhạc. Issue đề xuất hai cách sắp xếp, vì vậy hãy hỏi các maintainer xem nên dùng cách nào.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
music21 version
11.0.0b11
Problem summary
ChordReducer.run() was found to raise a TypeError when given a multi-part stream.Score whose instruments were not assigned partIds.
Steps to reproduce
from music21 import chord, instrument, note, stream
from music21.analysis.reduceChords import ChordReducer
upperInstrument = instrument.Instrument()
# upperInstrument.partId = 'P1'
lowerInstrument = instrument.Instrument()
# lowerInstrument.partId = 'P2'
upper = stream.Part([upperInstrument, stream.Measure([chord.Chord('C4 E4', type='whole')])])
lower = stream.Part([lowerInstrument, stream.Measure([note.Note('G4', type='whole')])])
score = stream.Score([upper, lower])
ChordReducer().run(score)
TypeError: '<' not supported between instances of 'NoneType' and 'NoneType'
This error was discovered when calling ChordReducer.run() on scores loaded from MIDI.
Expected vs. actual behavior
Expected ChordReducer.run(score) to complete without error; instead, raises TypeError at music21/tree/timespanTree.py, line 743, in TimespanTree.allParts().
More information
ChordReducer.run() calls TimespanTree.allParts() internally, which returns a list of the tree's parts. This list is ordered by the partId of each part's first instrument, using the following sort:
parts = sorted(parts, key=lambda x: x.getInstrument().partId)
x.getInstrument() returns the first available instrument in the part, or a new default instrument. In either case, the partId could be None.
One possible fix for the NoneType comparison: having allParts() utilize the input source's ordering to sort the parts. The ordering is available for at least this use case, since ChordReducer.run() already validates that its input is a stream.Score, and the TimespanTree that it uses already keeps track of the source in its source attribute. For just the stream.Score case, allParts() could then return the parts in order of their appearance in the score. Or, more generally, for a solution that works with other stream types that TimespanTree can process, allParts() could always return the list of parts ordered using the source's ordering.
Applying chordify() to the input score beforehand (stream.Score([score.chordify()])), avoids the TypeError being raised, although the chordified score contains just one part.
- Ngôn ngữ chính
- Python
- Star
- 2.6k
- Fork
- 459
- Merge trung bình
- 1 ngày 7 giờ
- Pull request đã merge (30 ngày)
- 40
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của cuthbertLab/music21
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
cuthbertLab/music21#2084 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
cuthbertLab/music21#2082 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
cuthbertLab/music21#2055 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Slur bezier-x/y from start element gets overwritten by stop element's valuesCó thể làm lại được @bingliscodes đã nhận 10 ngày trước và không có pull request nào đang mở. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
cuthbertLab/music21#2019 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
cuthbertLab/music21#1986 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của cuthbertLab/music21
Issue tương tự
-
bot-triaged module: LrScheduler module: optimizer triaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation glm5 llm-model
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
vllm-project/vllm-ascend#19062 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Author Page: shuai-zhao-llmĐang mởauthor-page correction
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
acl-org/acl-anthology#10496 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Issue Type: Bug Report
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
celery/celery#10875 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
SasanLabs/VulnerableApp#836 ·
Maintainer thường phản hồi trong vòng 1 ngày