import numpy as np
import pandas as pd

from suite20_reporting import metric_row, mean_fold_summary, macro_summary, temporal_uplift_table


def test_reporting_pipeline():
    y = np.array([0, 0, 1, 0, 1, 0, 0, 1])
    p1 = np.array([.1, .2, .8, .3, .7, .1, .4, .9])
    p2 = np.array([.2, .3, .7, .4, .6, .2, .5, .8])
    rows = []
    for fold in [6, 7]:
        rows.append(metric_row(fold, "f", "suite20_transformer", y, p1))
        rows.append(metric_row(fold, "f", "suite20_flat", y, p2))
    meanf = mean_fold_summary(rows, [6, 7])
    assert len(meanf) == 2
    macro = macro_summary(meanf)
    assert len(macro) == 2
    uplift = temporal_uplift_table(meanf)
    assert len(uplift) == 1
    assert uplift.delta_ap.iloc[0] >= 0
