From f2f7bad691a48d49716f26f5b5b095b39d171c47 Mon Sep 17 00:00:00 2001 From: Tim Beyer <35711942+TimFelixBeyer@users.noreply.github.com> Date: Sun, 3 Mar 2024 16:45:42 +0100 Subject: [PATCH] Fix #1685: Harmony parsing errors with doubled characters (#1688) The code intended to only remove the parsed `chordKind` from the string, but in cases where the `chordKind` char occurs multiple times, this would remove all occurrences of the char. --- music21/harmony.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/music21/harmony.py b/music21/harmony.py index b3ea94eff..ab8611636 100644 --- a/music21/harmony.py +++ b/music21/harmony.py @@ -1890,7 +1890,7 @@ def _getKindFromShortHand(self, sH): for charString in getAbbreviationListGivenChordType(chordKind): if sH == charString: self.chordKind = chordKind - return originalsH.replace(charString, '') + return originalsH[len(sH):] return originalsH def _hasPitchAboveC4(self, pitches): @@ -3162,6 +3162,12 @@ def testExpressSusUsingAlterations(self): self.assertEqual(ch1.pitches, ch2.pitches) + def testDoubledCharacters(self): + ch1 = ChordSymbol('Co omit5') + ch2 = ChordSymbol('Cdim omit5') + + self.assertEqual(ch1.pitches, ch2.pitches) + def x_testPower(self): ''' power chords should not have inversions