from grav_bridge_i.data import load_and_validate
from grav_bridge_i.splits import build_group_folds

def test_group_splits_have_no_leakage(radial_path, signature_path, config):
    data = load_and_validate(radial_path, signature_path, config).joined.reset_index(drop=True)
    folds, registry = build_group_folds(data, config)
    groups = data[config["columns"]["group"]].astype(str).to_numpy()
    assert registry.galaxy_id.nunique() == 121
    for train, test in folds:
        assert not (set(groups[train]) & set(groups[test]))
