예제 #1
0
    def create_quality(self, notation, capital_note=True):
        """Create a `Quality`.

        Create a `Quality` from its notation and whether the `root` of the `Chord` was uppercase.

        Parameters
        ----------
        notation : str
            The `Quality`'s notation.
        *capital_note : boolean, Optional
            Selector for the case of the `root` of the `Chord`. Default True when optional.

        Returns
        -------
        Quality
            The created `Quality`.

        Examples
        --------
        >>> QE = QualityEditor()
        >>> QE.create_quality("sus4")
        sus4 quality
        >>> QE.create_quality("maj7")
        major seventh quality

        """
        if notation is None:
            if capital_note:
                return Quality("major")
            return Quality("minor")
        rgx = re.match(QualityEditor.quality_pattern, notation, re.UNICODE)
        if rgx.group(2):  # power
            return Quality("power")
        alt5 = self._parse_alt5(rgx.group(20))
        quality_str = self._parse_base(rgx, alt5, capital_note)
        ext_str = self._parse_ext(rgx, alt5, capital_note)
        flat_ext = self._parse_flat_ext(rgx.group(13))
        return Quality(quality_str, ext_str, flat_ext)
예제 #2
0
def test_sym_base(quality, ext, sym):
    q = Quality(quality, ext)
    assert sym == q.base_symbols
예제 #3
0
def test_sym(quality, ext, sym):
    q = Quality(quality, ext)
    assert sym == q.symbols
예제 #4
0
def test_degree(quality, ext, degree):
    q = Quality(quality, ext)
    assert degree == q.degrees
예제 #5
0
def test_check_major():
    with pytest.raises(ValueError):
        Quality("major", "seventh")
예제 #6
0
def test_interval(quality, ext, interval):
    q = Quality(quality, ext)
    assert interval == q.intervals
예제 #7
0
def test_check_diminished():
    with pytest.raises(ValueError):
        Quality("diminished", "seventh")
예제 #8
0
def test_short_halfdim():
    q = Quality("half-diminished", "eleventh")
    assert "m11\u266d5" == str(q)
예제 #9
0
def test_check_flat_sevenths():
    with pytest.raises(ValueError):
        Quality("major", "major seventh", True)
예제 #10
0
def test_check_diminished_2():
    with pytest.raises(ValueError):
        Quality("minor", "diminished seventh")
예제 #11
0
def test_equality():
    q1 = Quality("major", "major seventh")
    q2 = Quality("major", "major seventh")
    assert q1 == q2
예제 #12
0
def test_equality_not_implemented():
    q = Quality("major")
    assert q != len
예제 #13
0
def test_str():
    q = Quality("major", "major seventh")
    assert "maj7" == str(q)
예제 #14
0
def test_long_repr_with_flat_ext(quality, ext, name):
    q = Quality(quality, ext, True)
    assert name + " quality" == repr(q)
예제 #15
0
def test_long_repr(quality, name):
    q = Quality(quality)
    assert name + " quality" == repr(q)
예제 #16
0
def test_short():
    q = Quality("diminished")
    assert "dim" == str(q)
예제 #17
0
def test_short_flat():
    q = Quality("minor", "ninth", True)
    assert "m\u266d9" == str(q)
예제 #18
0
def test_base_interval(quality, interval):
    q = Quality(quality)
    assert interval == q.base_intervals
예제 #19
0
def test_short_sus():
    q = Quality("sus4", "seventh")
    assert "7sus" == str(q)
예제 #20
0
def test_base_degree(quality, degree):
    q = Quality(quality)
    assert degree == q.base_degrees