From a40e41a7f04b829ef02e9d8cb66a7dea1a78af70 Mon Sep 17 00:00:00 2001 From: Malcolm Sailor Date: Thu, 8 Sep 2022 11:20:52 -0400 Subject: [PATCH] transpose key of RomanNumeral --- music21/roman.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/music21/roman.py b/music21/roman.py index 2ef2e4cf5a..7d3a5b6cd2 100644 --- a/music21/roman.py +++ b/music21/roman.py @@ -42,6 +42,8 @@ # TODO: setting inversion should change the figure +T = t.TypeVar('T', bound='RomanNumeral') + # ----------------------------------------------------------------------------- @@ -3089,6 +3091,28 @@ def _updatePitches(self): f'_updatePitches() was unable to derive pitches from the figure: {self.figure!r}' ) # pragma: no cover + def transpose(self, value, *, inPlace=False) -> t.Optional[T]: + ''' + Overrides :meth:`~music21.harmony.Harmony.transpose` so that `key` + attribute is transposed as well. + + >>> rn = roman.RomanNumeral('I', 'C') + >>> rn + + >>> rn.transpose(4) + + >>> rn.transpose(-4, inPlace=True) + >>> rn + + ''' + post = super().transpose(value, inPlace=inPlace) + if not inPlace: + post.key = self.key.transpose(value, inPlace=False) + return post + else: + self.key.transpose(value, inPlace=True) + return None + # PUBLIC PROPERTIES #