From 56fd24c521c20b7fc20fb2d066e2af05182e91d5 Mon Sep 17 00:00:00 2001 From: Jeremy Nickurak <1140821+nickurak@users.noreply.github.com> Date: Sat, 30 Dec 2023 22:05:21 -0700 Subject: [PATCH] Test (and correct) that all "M" and "maj" qualities are synonyms for 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 --- pychord/constants/qualities.py | 12 +++++++++++- test/test_quality.py | 15 +++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/pychord/constants/qualities.py b/pychord/constants/qualities.py index 94ae1c6..df93ef9 100644 --- a/pychord/constants/qualities.py +++ b/pychord/constants/qualities.py @@ -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)), @@ -78,7 +82,9 @@ ('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)), @@ -86,7 +92,9 @@ ('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)), @@ -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)), ] diff --git a/test/test_quality.py b/test/test_quality.py index 97518d0..87fc128 100644 --- a/test/test_quality.py +++ b/test/test_quality.py @@ -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):