Repository navigation
(AI) Order TimespanTree.allParts() by the source score - #2089
Merged
Merged
Conversation
allParts() sorted the parts by their instrument's partId, which raised a TypeError when the parts had no partId (as with MIDI imports) and put P10 before P2. Use the order of the parts in the source score instead, falling back to partId for parts that are not in the source. Fixes cuthbertLab#2074
Member
|
thanks! looks good. we're moving more towards |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2074.
TimespanTree.allParts()sorted parts bygetInstrument().partId. Parts without a partId, which is common for MIDI imports, madeChordReducer.run()raiseTypeError: '<' not supported between instances of 'NoneType' and 'NoneType'.As the issue suggests,
allParts()now returns the parts in the order they appear in the tree's source when the source has parts, such as a Score. Any other parts come after them, sorted by partId, and a missing partId no longer breaks the sort. This also matters forChordReducer.splitByBass(), which takes the last part as the bass: a string sort on partId putP10beforeP2.Tests:
allParts().testPartsWithoutPartIdruns the example from the issue throughChordReducer().run().testPartsOrderedAsInScorecovers partIds that don't sort in score order.timespanTreeandreduceChordsmodule tests pass, including the bwv66.6 doctests, whose part order is unchanged. Pylint is 10/10.AI-assisted (Claude). I reviewed the code and ran the tests.