File size: 836 Bytes
99e41a8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import json

from robotics.eval.stats import compare, main, wilson


def test_wilson_known_value():
    lo, hi = wilson(45, 50)
    assert abs(lo - 0.786) < 0.005 and abs(hi - 0.957) < 0.005


def test_wilson_edges():
    assert wilson(0, 0) == (0.0, 1.0)
    lo, hi = wilson(50, 50)
    assert hi == 1.0 and lo > 0.9


def test_compare_significance():
    assert compare(30, 100, 50, 100)["p_value"] < 0.01
    assert compare(50, 100, 52, 100)["p_value"] > 0.5


def test_cli(tmp_path, capsys):
    f = tmp_path / "r.jsonl"
    f.write_text("\n".join(json.dumps({"run": r, "suite": "s", "success": i < k})
                           for r, k in [("A", 3), ("B", 8)] for i in range(10)))
    main([str(f), "--compare", "A", "B"])
    out = capsys.readouterr().out
    assert "30.0%" in out and "80.0%" in out and "B - A: +50.0%" in out