コード例 #1
0
ファイル: test_evaluation.py プロジェクト: washingtonm/triage
def test_generate_binary_at_x():
    input_list = [0.9, 0.8, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.6]

    # bug can arise when the same value spans both sides of threshold
    assert generate_binary_at_x(input_list, 50, 'percentile') == \
        [1, 1, 1, 1, 1, 0, 0, 0, 0, 0]

    assert generate_binary_at_x(input_list, 2) == \
        [1, 1, 0, 0, 0, 0, 0, 0, 0, 0]
コード例 #2
0
def test_generate_binary_at_x():
    input_array = np.array([0.9, 0.8, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.6])

    # bug can arise when the same value spans both sides of threshold
    assert_array_equal(generate_binary_at_x(input_array, 50, "percentile"),
                       np.array([1, 1, 1, 1, 1, 0, 0, 0, 0, 0]))

    assert_array_equal(generate_binary_at_x(input_array, 2),
                       np.array([1, 1, 0, 0, 0, 0, 0, 0, 0, 0]))

    assert_array_equal(generate_binary_at_x(np.array([]), 2), np.array([]))