Skip to content

Separate Chord.inversion(int) to Chord.setInversion() - #2050

Merged
mscuthbert merged 1 commit into
masterfrom
setInversion
Oct 1, 2026
Merged

mscuthbert merged 1 commit into
masterfrom
setInversion

Conversation

@mscuthbert

Copy link
Copy Markdown
Member

setInversion(newInversion, *, transpose=True, inPlace=False) takes over the setting half of inversion().

This behaves like most m21 methods (and unlike before) in that inPlace=False is default.

transposeOnSet becomes just transpose, since it's entirely about setting.

setInversion(None, inPlace=True) removes overridden inversions (a missing feature that was thought to exist since 2012.

Old Chord.inversion(2) for setting is still there in v11. In v12 it will be deprecated and give a warning. In v13 it will be removed

Fix some docs and errors.

AI-assisted (Claude)

setInversion(newInversion, *, transpose=True, inPlace=False) takes over
the setting half of inversion(). Unlike inversion(n), it returns a copy
by default. inversion(n) still works in place for v11; deprecate in v12,
remove in v13. inversion() overloads now reject keywords that the
get or set form ignores.

setInversion(None) clears a stored inversion. harmony's
self.inversion(None, transposeOnSet=False) was meant to do this
(since 2012) but None always fell through to the getter; it now calls
setInversion(None, inPlace=True).

Also: inversion() docs said max 5 / 0 for unusual / None for empty;
the code has returned 6 / -1 / -1 since 2015 / 2022.

AI-assisted (Claude)
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 93.356% (-0.001%) from 93.357% — setInversion into master

@mscuthbert
mscuthbert merged commit 7e173a9 into master Oct 1, 2026
8 checks passed
@mscuthbert
mscuthbert deleted the setInversion branch October 1, 2026 00:08
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.

2 participants