from __future__ import annotations

import pandas as pd

from experiment_b_suite.redundancy import prune_correlated_features


def test_correlation_cluster_keeps_highest_priority_representative():
    X = pd.DataFrame(
        {
            "a": [1, 2, 3, 4, 5],
            "b": [2, 4, 6, 8, 10],
            "c": [1, 0, 1, 0, 1],
        }
    )
    report = pd.DataFrame(
        {
            "feature": ["a", "b", "c"],
            "priority_score": [0.10, 0.30, 0.20],
        }
    )
    kept, manifest = prune_correlated_features(X, ["a", "b", "c"], report, 0.95)
    assert kept == ["b", "c"]
    assert manifest["representative_for"]["a"] == "b"
    assert manifest["cluster_count"] == 2
