Ejemplo n.º 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)
Ejemplo n.º 2
0
def test_sym_base(quality, ext, sym):
    q = Quality(quality, ext)
    assert sym == q.base_symbols
Ejemplo n.º 3
0
def test_sym(quality, ext, sym):
    q = Quality(quality, ext)
    assert sym == q.symbols
Ejemplo n.º 4
0
def test_degree(quality, ext, degree):
    q = Quality(quality, ext)
    assert degree == q.degrees
Ejemplo n.º 5
0
def test_check_major():
    with pytest.raises(ValueError):
        Quality("major", "seventh")
Ejemplo n.º 6
0
def test_interval(quality, ext, interval):
    q = Quality(quality, ext)
    assert interval == q.intervals
Ejemplo n.º 7
0
def test_check_diminished():
    with pytest.raises(ValueError):
        Quality("diminished", "seventh")
Ejemplo n.º 8
0
def test_short_halfdim():
    q = Quality("half-diminished", "eleventh")
    assert "m11\u266d5" == str(q)
Ejemplo n.º 9
0
def test_check_flat_sevenths():
    with pytest.raises(ValueError):
        Quality("major", "major seventh", True)
Ejemplo n.º 10
0
def test_check_diminished_2():
    with pytest.raises(ValueError):
        Quality("minor", "diminished seventh")
Ejemplo n.º 11
0
def test_equality():
    q1 = Quality("major", "major seventh")
    q2 = Quality("major", "major seventh")
    assert q1 == q2
Ejemplo n.º 12
0
def test_equality_not_implemented():
    q = Quality("major")
    assert q != len
Ejemplo n.º 13
0
def test_str():
    q = Quality("major", "major seventh")
    assert "maj7" == str(q)
Ejemplo n.º 14
0
def test_long_repr_with_flat_ext(quality, ext, name):
    q = Quality(quality, ext, True)
    assert name + " quality" == repr(q)
Ejemplo n.º 15
0
def test_long_repr(quality, name):
    q = Quality(quality)
    assert name + " quality" == repr(q)
Ejemplo n.º 16
0
def test_short():
    q = Quality("diminished")
    assert "dim" == str(q)
Ejemplo n.º 17
0
def test_short_flat():
    q = Quality("minor", "ninth", True)
    assert "m\u266d9" == str(q)
Ejemplo n.º 18
0
def test_base_interval(quality, interval):
    q = Quality(quality)
    assert interval == q.base_intervals
Ejemplo n.º 19
0
def test_short_sus():
    q = Quality("sus4", "seventh")
    assert "7sus" == str(q)
Ejemplo n.º 20
0
def test_base_degree(quality, degree):
    q = Quality(quality)
    assert degree == q.base_degrees