MCPcopy Create free account
hub / github.com/idank/explainshell / test_buckets_and_stats

Method test_buckets_and_stats

tests/test_manager.py:2773–2788  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2771 self.assertEqual(s.buckets, {"0": 0, "1-5": 0, "6-15": 0, "16-50": 0, "50+": 0})
2772
2773 def test_buckets_and_stats(self) -> None:
2774 from explainshell.extraction.report import OptionCountSummary
2775
2776 counts = [0, 0, 1, 3, 5, 7, 10, 15, 16, 30, 50, 51, 100]
2777 s = OptionCountSummary.from_counts(counts)
2778 assert s is not None
2779 self.assertEqual(s.n, 13)
2780 self.assertEqual(s.total, sum(counts))
2781 self.assertEqual(s.max, 100)
2782 self.assertEqual(
2783 s.buckets,
2784 {"0": 2, "1-5": 3, "6-15": 3, "16-50": 3, "50+": 2},
2785 )
2786 # mean = sum/n; median is the middle of sorted list (n=13 -> index 6 = 10)
2787 self.assertAlmostEqual(s.mean, sum(counts) / 13, places=2)
2788 self.assertEqual(s.median, 10.0)
2789
2790 def test_single_count_p90_fallback(self) -> None:
2791 """statistics.quantiles needs >= 2 points; single point falls back."""

Callers

nothing calls this directly

Calls 1

from_countsMethod · 0.80

Tested by

no test coverage detected