Tweak Leonard notation to use T and E

This commit is contained in:
Jonathan Harker 2024-09-27 07:11:20 +12:00
parent eea441b561
commit 36de6f409b
3 changed files with 9 additions and 7 deletions

View file

@ -235,8 +235,9 @@ class SetClass(list):
"""
Returns a string representation of this set class using subscripts to denote the adjacency
intervals between the pitch classes instead of commas, and the overall brightness (sum of
pitch class values) denoted as a superscript. For example, Forte 5-20, {0,1,5,6,8} is
notated [01568]²
pitch class values) denoted as a superscript. In standard tonality (T=12) the letters T and
E are used for pitch classes 10 and 11. For example, Forte 7-34, {0,1,3,4,6,8,10} is
notated [013468T₂]³².
"""
# Return numbers as subscript and superscript strings:
def subscript(n: int) -> str:
@ -251,7 +252,8 @@ class SetClass(list):
sub = subscript(self.adjacency_intervals[i])
pitches += f"{pitch}{sub}"
sup = superscript(self.brightness)
return f"[{pitches}]⁽{sup}"
s = f"[{pitches}]⁽{sup}"
return s.replace('10', 'T').replace('11', 'E') if self.tonality == 12 else s
# Class methods -----------------------------------------------------------

View file

@ -57,4 +57,4 @@ def test_empty_complement_dozenal_notation():
def test_empty_complement_leonard_notation():
assert f121.leonard_notation == '[0₁1₁2₁3₁4₁5₁6₁7₁8₁9₁10₁11₁]⁽⁶⁶⁾'
assert f121.leonard_notation == '[0₁1₁2₁3₁4₁5₁6₁7₁8₁9₁T₁E₁]⁽⁶⁶⁾'

View file

@ -106,7 +106,7 @@ def test_brightest_form():
b = f520.brightest_form
assert b in f520.versions
assert b == SetClass(0, 4, 5, 9, 10)
assert b.leonard_notation == '[0₄4₁5₄9₁10₂]⁽²⁸⁾'
assert b.leonard_notation == '[0₄4₁5₄9₁T₂]⁽²⁸⁾'
def test_darkest_form():
@ -184,14 +184,14 @@ def test_complement_brightest_form():
b = f520.complement.brightest_form
assert b in f520.complement.versions
assert b == SetClass(0, 3, 5, 6, 7, 10, 11)
assert b.leonard_notation == '[0₃3₂5₁6₁7₃10₁11₁]⁽⁴²⁾'
assert b.leonard_notation == '[0₃3₂5₁6₁7₃T₁E₁]⁽⁴²⁾'
def test_complement_darkest_form():
d = f520.complement.darkest_form
assert d in f520.complement.versions
assert d == SetClass(0, 1, 2, 5, 6, 7, 10)
assert d.leonard_notation == '[0₁1₁2₃5₁6₁7₃10₂]⁽³¹⁾'
assert d.leonard_notation == '[0₁1₁2₃5₁6₁7₃T₂]⁽³¹⁾'
def test_complement_leonard_notation():