def test_top_k(): y_true = np.array([True, True, False, False]) y_score = np.array([.25, 1, 0, .5]) assert top_k(y_true, y_score,3) == (2,3)
def test_top_k_len_error(): y_true = np.array([True, False]) y_score = np.array([1,0,.5]) with pytest.raises(ValueError): top_k(y_true, y_score, 3)
def test_top_k_0(): y_true = np.array([True]) y_score = np.array([1]) assert top_k(y_true, y_score, 0) == (0,0)
def test_top_k_extrapolate_empty(): y_true = np.array([np.nan, False, np.nan]) y_score = np.array([1,0,.5]) assert top_k(y_true, y_score, 2, extrapolate=True) == (0,0)
def test_top_k_extrapolate(): y_true = np.array([True, False, np.nan]) y_score = np.array([1,0,.5]) assert top_k(y_true, y_score,2, extrapolate=True) == (1,1)
def test_top_k_null(): y_true = np.array([True, False, np.nan]) y_score = np.array([1,0,.5]) assert top_k(y_true, y_score,2) == (1,2)