vinsvanfer / music21

Automatically exported from code.google.com/p/music21
0 stars 0 forks source link

Calling KeySignature.getScale() on C raises an exception #58

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
This seems to be because the sharps property is set to None on the 
KeySignature() object. 

Here is a console trace of the exception

=======
In [17]: ks = key.KeySignature()

In [18]: ks.getScale()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/home/Documents/code/git/<ipython console> in <module>()

/home/Documents/code/music21/music21/key.pyc in getScale(self)
    523         '''
    524         from music21 import scale
--> 525         pitchObj, mode = self._getPitchAndMode()
    526         if mode in [None, 'major']:
    527             return scale.MajorScale(pitchObj)

/home/Documents/code/music21/music21/key.pyc in _getPitchAndMode(self)
    309             pitchObj = sharpsToPitch(self.sharps + 3)
    310         else:
--> 311             pitchObj = sharpsToPitch(self.sharps)
    312         return pitchObj, self.mode
    313 

/home/Documents/code/music21/music21/key.pyc in sharpsToPitch(sharpCount)
     70 
     71     intervalObj = interval.Interval(intervalStr)
---> 72     for x in range(abs(sharpCount)):
     73         pitchInit = intervalObj.transposePitch(pitchInit)
     74     pitchInit.octave = None

TypeError: bad operand type for abs(): 'NoneType'
=======

Original issue reported on code.google.com by andrew.hankinson on 30 Jan 2011 at 6:36

GoogleCodeExporter commented 9 years ago
One small followup: manually setting ks.sharps = 0, and then running 
ks.getScale() works as expected.

Original comment by andrew.hankinson on 30 Jan 2011 at 6:37

GoogleCodeExporter commented 9 years ago
sorry I missed this -- fixed now.  Will be in next version.

Original comment by cuthbert on 30 May 2011 at 8:37