Something went wrong. Try again.
bayes for days
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140"""The standard report says what happened, and says when it cannot."""
from __future__ import annotations
import jsonimport tempfileimport unittestfrom pathlib import Path
from sds.runreport import render
MATCH = { "outcome": "victory", "victoryTeam": 1, "round": 8, "players": [ { "name": "sds North", "kind": "sds", "team": 1, "id": 0, "bvStart": 6000, "bvRemaining": 3000, "turns": { "count": 2, "totalMillis": 200, "maxMillis": 150, "millis": [50, 150], "byRound": {"1": {"millis": 200, "turns": 2}}, }, "sds": { "prone": 4, "pronePinned": 1, "phases": { "movement": { "decisions": 10, "answered": 8, "defaulted": 2, "timedOut": 2, "illegal": 1, "failed": 0, "eligible": 20, "differed": 5, } }, }, }, { "name": "princess South", "kind": "princess", "team": 2, "id": 1, "bvStart": 6000, "bvRemaining": 1200, "sds": {}, "turns": { "count": 2, "totalMillis": 800, "maxMillis": 600, "millis": [200, 600], "byRound": {"1": {"millis": 800, "turns": 2}}, }, }, ],}
class TheReportCoversWhatARunIsJudgedOn(unittest.TestCase): def setUp(self): self.run = Path(tempfile.mkdtemp()) / "20260825T000000Z-bench" self.run.mkdir(parents=True) (self.run / "a.json").write_text(json.dumps(MATCH))
def test_every_section_is_present(self): text = render(self.run) for head in ( "## What ran", "## Outcome", "## Faults", "## Speed", "## Effort", "## Weapons", ): self.assertIn(head, text)
def test_the_win_rate_carries_an_interval(self): text = render(self.run) self.assertIn("| sds | 1 | 100.0%", text) self.assertIn("95% CI", text)
def test_timeouts_are_their_own_column(self): # A timeout and "nothing to choose" both end as an inert default and # were one number, which is how a deadline inside the working range hid. text = render(self.run) self.assertIn("timed out", text) row = next(r for r in text.splitlines() if "| movement |" in r) self.assertIn("| 2 |", row) self.assertIn("| 1 |", row)
def test_both_sides_are_timed_and_the_faster_is_named(self): text = render(self.run) self.assertIn("| princess |", text) self.assertIn("sds is 4.00x faster per turn than princess", text)
def test_differed_is_not_called_exploration(self): # `differed` counts the force picking a unit that is not the host's # next one. Calling it exploration survived into a run with # exploration switched off, where it reported 18%. text = render(self.run) self.assertIn("chose its own unit order", text) self.assertNotIn("explored", text)
def test_a_run_with_no_timing_says_so_rather_than_reporting_zero(self): bare = dict(MATCH) bare["players"] = [{k: v for k, v in p.items() if k != "turns"} for p in MATCH["players"]] (self.run / "a.json").write_text(json.dumps(bare)) text = render(self.run) self.assertIn("No turn timing in this run", text) self.assertNotIn("0.00x faster", text)
def test_a_run_with_no_manifest_says_nothing_can_check_it(self): self.assertIn("no manifest", render(self.run))
def test_the_manifest_is_read_when_it_is_there(self): (self.run / "manifest.json").write_text( json.dumps( { "basis": "abc123", "features": ["a", "b"], "commit": "deadbee", "epoch": 4, "bot": "sds-bot --weights w.json", "explore": False, } ) ) text = render(self.run) self.assertIn("`abc123`", text) self.assertIn("no exploration", text)