@@ -263,38 +263,47 @@ def _reprInternal(self):
263263 summary += ' ' .join ([p .name for p in self .pitches ])
264264 return summary
265265
266- # PRIVATE METHODS #
266+ # PROTECTED METHODS #
267267 def _parseFigure (self ):
268268 '''
269- subclass this in extensions (SO WHY IS IT PRIVATE??? )
269+ subclass this in extensions (protected in TypeScript/Java speak )
270270 '''
271271 return
272272
273273 def _updatePitches (self ):
274274 '''
275- subclass this in extensions (SO WHY IS IT PRIVATE??? )
275+ subclass this in extensions (protected in TypeScript/Java speak )
276276 '''
277277 return
278278
279- def _updateFromParameters (self , root , bass , inversion : int | None = None ):
279+ def _updateFromParameters (
280+ self ,
281+ root : str | pitch .Pitch | None ,
282+ bass : str | pitch .Pitch | None ,
283+ inversion : int | None = None
284+ ) -> None :
280285 '''
281286 This method must be called twice, once before the pitches
282287 are rendered, and once after. This is because after the pitches
283- are rendered, the root() and bass() becomes reset by the chord class,
288+ are rendered, the root() and bass() become reset by the chord class,
284289 but we want the objects to retain their initial root, bass, and inversion.
285290 '''
286291 if root and isinstance (root , str ):
287292 root = common .cleanedFlatNotation (root )
288293 self .root (pitch .Pitch (root , octave = 3 ))
289294 elif root is not None :
290295 self .root (root )
296+
297+ # set inversion first...
298+ if inversion is not None :
299+ self .inversion (inversion , transposeOnSet = True )
300+
301+ # and then bass.
291302 if bass and isinstance (bass , str ):
292303 bass = common .cleanedFlatNotation (bass )
293304 self .bass (pitch .Pitch (bass , octave = 3 ), allow_add = True )
294305 elif bass is not None :
295306 self .bass (bass , allow_add = True )
296- if inversion is not None :
297- self .inversion (inversion , transposeOnSet = True )
298307
299308 # PUBLIC PROPERTIES #
300309
@@ -1609,7 +1618,7 @@ class ChordSymbol(Harmony):
16091618 # INITIALIZER #
16101619
16111620 def __init__ (self ,
1612- figure = None ,
1621+ figure : str | None = None ,
16131622 root : pitch .Pitch | str | None = None ,
16141623 bass : pitch .Pitch | str | None = None ,
16151624 inversion : int | None = None ,
@@ -2473,7 +2482,13 @@ class NoChord(ChordSymbol):
24732482 >>> nc2.pitches
24742483 ()
24752484 '''
2476- def __init__ (self , figure = None , kind = 'none' , kindStr = None , ** keywords ):
2485+ def __init__ (
2486+ self ,
2487+ figure : str | None = None ,
2488+ kind : str | None = 'none' ,
2489+ kindStr : str | None = None ,
2490+ ** keywords
2491+ ):
24772492 super ().__init__ (figure , kind = kind , kindStr = kindStr or figure or 'N.C.' , ** keywords )
24782493
24792494 if self ._figure is None :
@@ -2655,6 +2670,17 @@ def testChordSymbolSetsBassOctave(self):
26552670 b = d .bass ()
26562671 self .assertEqual (b .nameWithOctave , 'E-3' )
26572672
2673+ def testHarmonyPreservesInversionAndBass (self ):
2674+ '''
2675+ Test that bass is preserved even when both bass and inversion are given
2676+ '''
2677+ explicitFm6 = ChordSymbol (root = 'F' , bass = 'A-' , inversion = 1 , kind = 'minor' )
2678+ self .assertEqual (explicitFm6 .inversion (), 1 )
2679+ self .assertEqual (explicitFm6 .bass (find = False ).name , 'A-' )
2680+ self .assertEqual (explicitFm6 .root (find = False ).name , 'F' )
2681+ self .assertLess (explicitFm6 .bass (find = False ).octave ,
2682+ explicitFm6 .root (find = False ).octave )
2683+
26582684 def testClassSortOrderHarmony (self ):
26592685 '''
26602686 This tests a former bug in getContextByClass
0 commit comments