Skip to content

Commit

Permalink
Test (and correct) that all "M" and "maj" qualities are synonyms for …
Browse files Browse the repository at this point in the history
…each other (#92)

* Test that all "M" and "maj" qualities are synonyms for each other

The existence of, for example Cmaj13, may suggest the existence of
CM13, which currently doesn't exist

* Add missing maj/M equivalent synonyms

---------

Co-authored-by: Jeremy Nickurak <[email protected]>
  • Loading branch information
nickurak and Jeremy Nickurak authored Dec 31, 2023
1 parent 1fce0cd commit 56fd24c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pychord/constants/qualities.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,16 @@
('dim7', (0, 3, 6, 9)),
('M7', (0, 4, 7, 11)),
('maj7', (0, 4, 7, 11)),
('maj7+5', (0, 4, 8, 11)),
('M7+5', (0, 4, 8, 11)),
('mmaj7', (0, 3, 7, 11)),
('mM7', (0, 3, 7, 11)),
('add4', (0, 4, 5, 7)),
('majadd4', (0, 4, 5, 7)),
('Madd4', (0, 4, 5, 7)),
('madd4', (0, 3, 5, 7)),
('add9', (0, 4, 7, 14)),
('majadd9', (0, 4, 7, 14)),
('Madd9', (0, 4, 7, 14)),
('madd9', (0, 3, 7, 14)),
('sus4add9', (0, 5, 7, 14)),
Expand Down Expand Up @@ -78,15 +82,19 @@
('11', (0, 7, 10, 14, 17)),
('7+11', (0, 4, 7, 10, 18)),
('7#11', (0, 4, 7, 10, 18)),
('maj7+11', (0, 4, 7, 11, 18)),
('M7+11', (0, 4, 7, 11, 18)),
('maj7#11', (0, 4, 7, 11, 18)),
('M7#11', (0, 4, 7, 11, 18)),
('7b9#9', (0, 4, 7, 10, 13, 15)),
('7b9#11', (0, 4, 7, 10, 13, 18)),
('7#9#11', (0, 4, 7, 10, 15, 18)),
('7-13', (0, 4, 7, 10, 20)),
('7b13', (0, 4, 7, 10, 20)),
('m7add11', (0, 3, 7, 10, 17)),
('maj7add11', (0, 4, 7, 11, 17)),
('M7add11', (0, 4, 7, 11, 17)),
('mmaj7add11', (0, 3, 7, 11, 17)),
('mM7add11', (0, 3, 7, 11, 17)),
# 6 notes
('7b9b13', (0, 4, 7, 10, 13, 17, 20)),
Expand All @@ -101,5 +109,7 @@
('13+11', (0, 4, 7, 10, 18, 21)),
('13#11', (0, 4, 7, 10, 18, 21)),
('maj13', (0, 4, 7, 11, 14, 21)), # https://chord-c.com/guitar-chord/C/major-thirteenth/
('M7add13', (0, 4, 7, 9, 11, 14))
('M13', (0, 4, 7, 11, 14, 21)),
('maj7add13', (0, 4, 7, 9, 11, 14)),
('M7add13', (0, 4, 7, 9, 11, 14)),
]
15 changes: 15 additions & 0 deletions test/test_quality.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,21 @@ def test_invalid_eq(self):
with self.assertRaises(TypeError):
print(q == 0)

def subtest_quality_synonym(self, a, b):
with self.subTest(msg=f"{a}_has_{b}_synonym"):
a_quality = self.quality_manager.get_quality(a)
b_quality = self.quality_manager.get_quality(b)
self.assertEqual(a_quality, b_quality)

def test_maj_synonyms(self):
for q in self.quality_manager.get_qualities():
if q in ['M', 'maj']:
continue
if "maj" in q:
self.subtest_quality_synonym(q, q.replace("maj", "M"))
elif "M" in q:
self.subtest_quality_synonym(q, q.replace("M", "maj"))


class TestQualityManager(unittest.TestCase):

Expand Down

0 comments on commit 56fd24c

Please sign in to comment.