Skip to content

Include mode in pitchFromDegree cache key (fixes #1535) - #2051

Merged
mscuthbert merged 1 commit into
cuthbertLab:masterfrom
bingliscodes:fix-1535-octatonic-mode-cache
Oct 1, 2026
Merged

mscuthbert merged 1 commit into
cuthbertLab:masterfrom
bingliscodes:fix-1535-octatonic-mode-cache

Conversation

@bingliscodes

Copy link
Copy Markdown
Contributor

Fixes #1535

Add self.mode attribute to the AbstractScale base class and store the raw mode on AbstractOctatonicScale and AbstractDiatonicScale at the end of buildNetwork to keep mode and pitch network consistent.

Add mode derived from the abstract scale to the _PitchDegreeCacheKey to ensure scales that share the same type and tonic but different modes no longer share cache entries. Since the key is a tuple and some modes are lists (and can't be dict keys), they are converted with str(mode).

Three regression tests in test_scale_main.py covering two octatonic modes, two diatonic modes, and swapping .abstract

Notes for maintainers

@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 93.364% (+0.005%) from 93.359% — bingliscodes:fix-1535-octatonic-mode-cache into cuthbertLab:master

@mscuthbert
mscuthbert merged commit 12d2772 into cuthbertLab:master Oct 1, 2026
8 checks passed
@mscuthbert

Copy link
Copy Markdown
Member

Thanks! Great!

@bingliscodes
bingliscodes deleted the fix-1535-octatonic-mode-cache branch October 6, 2026 20:51
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.

Changing the mode of an octatonic scale does not invalidate _pitchDegreeCache

3 participants