Accidental's .client is never set, so Pitch (and from there Note) is never informed of alter changes
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ó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
Hướng nghiên cứu
Start with the Accidental and Pitch behavior described in the issue: inspect Accidental.set() and the Pitch.accidental setter, then trace how changes inform Note and Chord caches. Consider the listed sharing, deepcopy, performance, and pickle-version concerns before choosing an approach. Done means in-place accidental changes leave dependent cached results correct without breaking the noted behaviors.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Basically, we created a .client attribute for Accidental, but we never had anything set Accidental.client = parent-Pitch so nothing is ever informed.
It means we have a couple of choices: we can get rid of it (making accidental a bit faster) and saying that Pitch changes should always create new accidentals rather than changing the existing accidental's alter (eh...?) -- or set client and figure out the bugs and speed tradeoffs.
Not commiting to doing this now, but wanted to be aware of it.
Agent drafted text below -- read and makes sense
Changing an Accidental in place (p.accidental.set('natural'), p.accidental.alter = 0) does not tell the Pitch's Note or Chord, so cached answers like chord.commonName stay stale. Assigning a new accidental (p.accidental = 'natural') works. (Entirely AI written)
music21 version
11.0.0b10 (master at 9ad11788e)
Operating System(s) checked
macOS 15
Problem summary
Accidental has a _client slot, and Accidental.set() calls self._client.informClient() when it is set, but nothing in music21 ever sets it: the Pitch.accidental setter stores the Accidental without pointing it back at the Pitch.
Steps to reproduce
from music21 import chord
c = chord.Chord(['C4', 'E-4', 'G4'])
c.commonName # 'minor triad'
c.pitches[1].accidental.set('natural')
c.pitches[1].name # 'E'
c.commonName # 'minor triad' -- stale
c.isMinorTriad() # True -- stale
c = chord.Chord(['C4', 'E-4', 'G4'])
c.commonName
c.pitches[1].accidental = 'natural'
c.commonName # 'major triad' -- correct
Expected vs. actual behavior
Expected: any change to a Pitch's accidental clears its Note's (and Chord's) caches.
Actual: only assigning a new accidental through Pitch.accidental does.
More information
The obvious fix (value._client = self in the Pitch.accidental setter) is probably not the whole job, and other behavior may need to change or be optimized along with it:
- An Accidental can be shared by several Pitches (
p2.accidental = p1.accidental), and one_clientcan only point at one of them. Either the setter copies, or shared Accidentals become unsupported. - Every in-place
set()/.alter =/.name =/.modifier =would start clearing Note and Chord caches. Code that loops over pitches adjusting accidentals (makeAccidentals,updateAccidentalDisplay, transposition, enharmonic simplification) may pay for repeated cache clears;displayStatuschanges should probably not clear anything. Accidental.__deepcopy__currently copies_clientacross unchanged; it should set it toNone, asPitch.__deepcopy__does for its own_client.- Pickled scores would carry the new back-reference, so the cache version would need a bump.
Found while benchmarking Accidental creation for a planned speedup; that work will not change this behavior.
AI-assisted (Claude)
- 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
-
`TypeError` in `ChordReducer.run()` on multi-part `stream.Score` without instrument `partId`sĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
cuthbertLab/music21#2074 ·
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
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