示例#1
0
def test_init(input_, expected_semitones):
    if (isinstance(expected_semitones, type)
            and issubclass(expected_semitones, Exception)):
        with pytest.raises(expected_semitones):
            NumberedPitch(input_)
        return
    instance = NumberedPitch(input_)
    assert float(instance) == expected_semitones
示例#2
0
    ('dss,,', -32),
    ('fake', ValueError),
    (('bf', 2), -14),
    (('c', 4), 0),
    (('cs', 4), 1),
    (('dss', 1), -32),
    (('gff', 5), 17),
    (NamedPitch("bs'"), 12),
    (NamedPitch('c'), -12),
    (NamedPitch('cf,'), -25),
    (NamedPitch(), 0),
    (NamedPitchClass("cs'"), 1),
    (NamedPitchClass('c'), 0),
    (NamedPitchClass('cf,'), -1),  # TODO: Is this correct?
    (None, 0),
    (NumberedPitch("bs'"), 12),
    (NumberedPitch('c'), -12),
    (NumberedPitch('cf,'), -25),
    (NumberedPitch(), 0),
    (NumberedPitchClass("bs'"), 0),
    (NumberedPitchClass('c'), 0),
    (NumberedPitchClass('cf,'), 11),
])


@pytest.mark.parametrize('input_, expected_semitones', values)
def test_init(input_, expected_semitones):
    if (isinstance(expected_semitones, type)
            and issubclass(expected_semitones, Exception)):
        with pytest.raises(expected_semitones):
            NamedPitch(input_)
示例#3
0
    ('dss,,', 4),
    ('fake', ValueError),
    (('bf', 2), 10),
    (('c', 4), 0),
    (('cs', 4), 1),
    (('dss', 1), 4),
    (('gff', 5), 5),
    (NamedPitch("bs'"), 0),
    (NamedPitch('c'), 0),
    (NamedPitch('cf,'), 11),
    (NamedPitch(), 0),
    (NamedPitchClass("cs'"), 1),
    (NamedPitchClass('c'), 0),
    (NamedPitchClass('cf,'), 11),
    (None, 0),
    (NumberedPitch("bs'"), 0),
    (NumberedPitch('c'), 0),
    (NumberedPitch('cf,'), 11),
    (NumberedPitch(), 0),
    (NumberedPitchClass("bs'"), 0),
    (NumberedPitchClass('c'), 0),
    (NumberedPitchClass('cf,'), 11),
])


@pytest.mark.parametrize('input_, expected_semitones', values)
def test_init(input_, expected_semitones):
    if (isinstance(expected_semitones, type)
            and issubclass(expected_semitones, Exception)):
        with pytest.raises(expected_semitones):
            NamedPitchClass(input_)
示例#4
0
    ("dss,,", 4),
    ("fake", ValueError),
    (("bf", 2), 10),
    (("c", 4), 0),
    (("cs", 4), 1),
    (("dss", 1), 4),
    (("gff", 5), 5),
    (NamedPitch("bs'"), 0),
    (NamedPitch("c"), 0),
    (NamedPitch("cf,"), 11),
    (NamedPitch(), 0),
    (NamedPitchClass("cs'"), 1),
    (NamedPitchClass("c"), 0),
    (NamedPitchClass("cf,"), 11),
    (None, 0),
    (NumberedPitch("bs'"), 0),
    (NumberedPitch("c"), 0),
    (NumberedPitch("cf,"), 11),
    (NumberedPitch(), 0),
    (NumberedPitchClass("bs'"), 0),
    (NumberedPitchClass("c"), 0),
    (NumberedPitchClass("cf,"), 11),
])


@pytest.mark.parametrize("input_, expected_semitones", values)
def test_init(input_, expected_semitones):
    if isinstance(expected_semitones, type) and issubclass(
            expected_semitones, Exception):
        with pytest.raises(expected_semitones):
            NumberedPitchClass(input_)
示例#5
0
        ("dss,,", -32),
        ("fake", ValueError),
        (("bf", 2), -14),
        (("c", 4), 0),
        (("cs", 4), 1),
        (("dss", 1), -32),
        (("gff", 5), 17),
        (NamedPitch("bs'"), 12),
        (NamedPitch("c"), -12),
        (NamedPitch("cf,"), -25),
        (NamedPitch(), 0),
        (NamedPitchClass("cs'"), 1),
        (NamedPitchClass("c"), 0),
        (NamedPitchClass("cf,"), 11),
        (None, 0),
        (NumberedPitch("bs'"), 12),
        (NumberedPitch("c"), -12),
        (NumberedPitch("cf,"), -25),
        (NumberedPitch(), 0),
        (NumberedPitchClass("bs'"), 0),
        (NumberedPitchClass("c"), 0),
        (NumberedPitchClass("cf,"), 11),
    ]
)


@pytest.mark.parametrize("input_, expected_semitones", values)
def test_init(input_, expected_semitones):
    if isinstance(expected_semitones, type) and issubclass(
        expected_semitones, Exception
    ):
示例#6
0
    (-3, -3),
    (-4, -4),
    (0, 0),
    (1, 1),
    (2, 2),
    (3, 3),
    (4, 4),
    (NamedPitch("bs'"), 4),
    (NamedPitch('c'), 3),
    (NamedPitch('cf,'), 2),
    (NamedPitch(), 4),
    (NamedPitchClass("cs'"), 4),
    (NamedPitchClass('c'), 4),
    (NamedPitchClass('cf,'), 4),
    (None, 4),
    (NumberedPitch("bs'"), 5),
    (NumberedPitch('c'), 3),
    (NumberedPitch('cf,'), 1),
    (NumberedPitch(), 4),
    (NumberedPitchClass("bs'"), 4),
    (NumberedPitchClass('c'), 4),
    (NumberedPitchClass('cf,'), 4),
    (Octave(), 4),
    (Octave(3), 3),
    (Octave(5), 5),
]


@pytest.mark.parametrize('input_, expected_number', values)
def test_init(input_, expected_number):
    if (isinstance(expected_number, type)
示例#7
0
    (-3, -3),
    (-4, -4),
    (0, 0),
    (1, 1),
    (2, 2),
    (3, 3),
    (4, 4),
    (NamedPitch("bs'"), 4),
    (NamedPitch("c"), 3),
    (NamedPitch("cf,"), 2),
    (NamedPitch(), 4),
    (NamedPitchClass("cs'"), 4),
    (NamedPitchClass("c"), 4),
    (NamedPitchClass("cf,"), 4),
    (None, 4),
    (NumberedPitch("bs'"), 5),
    (NumberedPitch("c"), 3),
    (NumberedPitch("cf,"), 1),
    (NumberedPitch(), 4),
    (NumberedPitchClass("bs'"), 4),
    (NumberedPitchClass("c"), 4),
    (NumberedPitchClass("cf,"), 4),
    (Octave(), 4),
    (Octave(3), 3),
    (Octave(5), 5),
]


@pytest.mark.parametrize("input_, expected_number", values)
def test_init(input_, expected_number):
    if isinstance(expected_number, type) and issubclass(