MCPcopy
hub / github.com/MinishLab/semble / test_rerank_topk

Function test_rerank_topk

tests/test_ranking.py:9–21  ·  view source on GitHub ↗

rerank_topk: empty → []; penalise_paths=False respects raw scores; saturation decay keeps order.

()

Source from the content-addressed store, hash-verified

7
8
9def test_rerank_topk() -> None:
10 """rerank_topk: empty → []; penalise_paths=False respects raw scores; saturation decay keeps order."""
11 assert rerank_topk({}, top_k=5) == []
12
13 init_chunk = make_chunk("from .auth import authenticate", "src/semble/__init__.py")
14 impl_chunk = make_chunk("def authenticate(token): ...", "src/semble/auth.py")
15 ranked = rerank_topk({init_chunk: 2.0, impl_chunk: 1.0}, top_k=2, penalise_paths=False)
16 assert ranked[0][0] == init_chunk
17
18 saturated = [make_chunk(f"def fn_{i}(): pass", "big_file.py") for i in range(5)]
19 ranked_sat = rerank_topk({c: float(5 - i) for i, c in enumerate(saturated)}, top_k=5)
20 scores = [s for _, s in ranked_sat]
21 assert scores == sorted(scores, reverse=True)
22
23
24@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 2

rerank_topkFunction · 0.90
make_chunkFunction · 0.90

Tested by

no test coverage detected