Skip to content

Key the realization cache on the altered degrees - #2054

Open
float3 wants to merge 1 commit into
cuthbertLab:masterfrom
float3:realize-cache-altered-degrees
Open

float3 wants to merge 1 commit into
cuthbertLab:masterfrom
float3:realize-cache-altered-degrees

Conversation

@float3

@float3 float3 commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

realizeAscending and realizeDescending cached under the node, reference and range alone, so a realization with alteredDegrees and one without shared an entry. nextPitch realizes without them, and a harmonic minor then lost its raised seventh:

>>> sc = scale.HarmonicMinorScale('g4')
>>> sc.nextPitch('a4')
<music21.pitch.Pitch B-4>
>>> sc.pitches[6]
<music21.pitch.Pitch F5>

AI-assisted (Claude).

realizeAscending and realizeDescending cached a realization under the
node, reference and range alone. A realization asked for with
alteredDegrees and one asked for without them shared an entry, so
whichever came first answered for both. nextPitch realizes without the
alterations, and a harmonic minor scale lost its raised seventh after
one call:

    >>> sc = scale.HarmonicMinorScale('g4')
    >>> sc.nextPitch('a4')
    <music21.pitch.Pitch B-4>
    >>> sc.pitches[6]
    <music21.pitch.Pitch F5>

The key now carries each alteration's degree, direction and interval.
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 93.366%. remained the same — float3:realize-cache-altered-degrees into cuthbertLab:master

@mscuthbert

Copy link
Copy Markdown
Member

I think this moves me over the line to the position that it's time to get rid of alteredPitches -- i've never found them useful and they've only ever caused problems like this!

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.

3 participants