From bb1fc845286a38fd3950dba2aa2b2c7f789b4e84 Mon Sep 17 00:00:00 2001 From: Myke Cuthbert Date: Sun, 1 May 2022 14:37:56 -1000 Subject: [PATCH] Accidentally broke key.Key('F#m') etc. --- music21/harmony.py | 2 +- music21/key.py | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/music21/harmony.py b/music21/harmony.py index 9a156f102c..f82eea76ff 100644 --- a/music21/harmony.py +++ b/music21/harmony.py @@ -369,7 +369,7 @@ def key(self): >>> [str(p) for p in h1.pitches] ['D-2', 'F-2', 'A-2', 'C-3', 'E-3', 'G-3'] - >>> h1.key = 'CM' + >>> h1.key = 'CM' # = C-Major >>> [str(p) for p in h1.pitches] ['D-2', 'F-2', 'A-2', 'C-3', 'E-3', 'G-3'] diff --git a/music21/key.py b/music21/key.py index b9bdea5e09..c7576efd6c 100644 --- a/music21/key.py +++ b/music21/key.py @@ -775,15 +775,12 @@ def transposePitchFromC(self, p: pitch.Pitch, *, inPlace=False) -> Optional[pitc 'B--4' If inPlace is True then the original pitch is - modified. + modified and nothing is returned. >>> p5 = pitch.Pitch('C5') >>> ks.transposePitchFromC(p5, inPlace=True) - >>> p5.nameWithOctave 'E-5' - - Changed in v8: original pitch returned if inPlace=True ''' transInterval = None transTimes = 0 @@ -920,6 +917,13 @@ class Key(KeySignature, scale.DiatonicScale): , ] + If you prefer not to use uppercase and lowercase to distinguish major and minor, + the shorthand of CM or Cm can also be used: + + >>> key.Key('EM') + + >>> key.Key('F#m') + ''' _sharps = 0 _mode = None @@ -955,7 +959,7 @@ def __init__(self, elif isinstance(tonic, note.Note): tonicPitch = tonic.pitch else: - tonicPitch = pitch.Pitch(tonic) + tonicPitch = pitch.Pitch(tonicStr) KeySignature.__init__(self, sharps) scale.DiatonicScale.__init__(self, tonic=tonicPitch)