Пример #1
0
def test_hz_to_cent_wrong_ref_hz_type():
    # GIVEN
    hz_seq = [440]
    ref_hz = "non_numeric"

    # WHEN; THEN
    with pytest.raises(ValueError) as excinfo:
        hz_to_cent(hz_seq, ref_hz)

    assert (str(excinfo.value) == 'ref_hz must be a number.')
Пример #2
0
def test_hz_to_cent_ref_hz_lower_than_20000():
    # GIVEN
    hz_seq = [440]
    ref_hz = 20000.1

    # WHEN; THEN
    with pytest.raises(ValueError) as excinfo:
        hz_to_cent(hz_seq, ref_hz)

    assert (str(
        excinfo.value) == 'ref_hz must be lower than or equal to 20000 Hz.')
Пример #3
0
def test_hz_to_cent_wrong_hz_seq_type():
    # GIVEN
    hz_seq = "non_list_type"
    ref_hz = 440

    # WHEN; THEN
    with pytest.raises(ValueError) as excinfo:
        hz_to_cent(hz_seq, ref_hz)

    assert (str(
        excinfo.value) == 'hz_seq must be a List or numpy array of numbers.')
Пример #4
0
def test_hz_to_cent_min_hz_lower_than_20():
    # GIVEN
    hz_seq = [440]
    ref_hz = 220
    min_hz = 19.99

    # WHEN; THEN
    with pytest.raises(ValueError) as excinfo:
        hz_to_cent(hz_seq, ref_hz, min_hz)

    assert (str(
        excinfo.value) == 'min_hz must be higher than or equal to 20 Hz.')
Пример #5
0
def test_hz_to_cent_hz_seq_lower_than_20000():
    # GIVEN
    hz_seq = [20000.1]
    ref_hz = 440

    # WHEN; THEN
    with pytest.raises(ValueError) as excinfo:
        hz_to_cent(hz_seq, ref_hz)

    assert (str(
        excinfo.value) == 'hz_seq values must be lower than or equal to '
            '20000 Hz.')
Пример #6
0
def test_hz_to_cent_20k_hz_seq_20k_ref_hz():
    # GIVEN
    hz_seq = [20000]
    ref_hz = 20000

    # WHEN
    result = hz_to_cent(hz_seq, ref_hz)

    # THEN
    expected = np.array([0])
    np.testing.assert_equal(result, expected)
Пример #7
0
def test_hz_to_cent_hz_seq_two_elements():
    # GIVEN
    hz_seq = [440, 880]
    ref_hz = 440

    # WHEN
    result = hz_to_cent(hz_seq, ref_hz)

    # THEN
    expected = np.array([0, 1200])
    np.testing.assert_equal(result, expected)
Пример #8
0
def test_hz_to_cent_hz_seq_half_ref_hz():
    # GIVEN
    hz_seq = [440]
    ref_hz = 880

    # WHEN
    result = hz_to_cent(hz_seq, ref_hz)

    # THEN
    expected = np.array([-1200])
    np.testing.assert_equal(result, expected)
Пример #9
0
def test_hz_to_cent_hz_seq_double_ref_hz():
    # GIVEN
    hz_seq = [880]
    ref_hz = 440

    # WHEN
    result = hz_to_cent(hz_seq, ref_hz)

    # THEN
    expected = np.array([1200])
    np.testing.assert_equal(result, expected)
Пример #10
0
def test_hz_to_cent_hz_seq_ref_hz_same_numpy():
    # GIVEN
    hz_seq = np.array([440])
    ref_hz = 440

    # WHEN
    result = hz_to_cent(hz_seq, ref_hz)

    # THEN
    expected = np.array([0])
    np.testing.assert_equal(result, expected)
Пример #11
0
def test_hz_to_cent_nan_hz_seq():
    # GIVEN
    hz_seq = [np.nan]
    ref_hz = 220

    # WHEN
    result = hz_to_cent(hz_seq, ref_hz)

    # THEN
    expected = np.array([np.nan])
    np.testing.assert_equal(result, expected)
Пример #12
0
def test_hz_to_cent_50_hz_seq_25_ref_hz_100_min_hz():
    # GIVEN
    hz_seq = [50]
    ref_hz = 25
    min_hz = 100

    # WHEN
    result = hz_to_cent(hz_seq, ref_hz, min_hz)

    # THEN
    expected = np.array([np.nan])
    np.testing.assert_equal(result, expected)