Files
pokerfreak/tests/farm_richter_spec.py
T

50 lines
2.5 KiB
Python

# Spezifikation von messung/farm/nacht-0112/richter_antwort.py (passt der Sim-Richter zur Antwort-Tafel? Fold der Sim-Gegner auf unsere Einsaetze je Typ gegen die echte Zaehlung des VPIP-Typs).
# python3 tests/farm_richter_spec.py
import sys; sys.dont_write_bytecode = True
import os, unittest
HIER = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, os.path.join(HIER, "..", "messung", "farm", "nacht-0112"))
import richter_antwort as R # noqa: E402
class Baender(unittest.TestCase):
def test_sim_band_auf_tafel_band(self):
# Sim-Baender (batterie_v2.BAENDER): <0,4 | <0,6 | <0,9 | <1,3 | <2,5 | darueber; Tafel: <=0,45 | <=0,85 | <=1,3 | 99
self.assertEqual([R.tafel_band(i) for i in range(6)], [0.45, 0.85, 0.85, 1.3, 99.0, 99.0])
class Typen(unittest.TestCase):
def test_vpip_klasse_wie_antwort_eichung_rs(self):
self.assertEqual((R.vpip_typ(0.10), R.vpip_typ(0.22), R.vpip_typ(0.449), R.vpip_typ(0.45)), (1, 2, 2, 3))
class Zaehlen(unittest.TestCase):
def test_folds_der_sim_je_typ_strasse_band_nur_bets_auf_turn_und_river(self):
zeilen = [{"typ": "nit", "engine": "motor", "mk": {"fz": [["T", 0, True, "B"], ["T", 0, False, "B"], ["F", 0, True, "B"], ["R", 3, True, "R"]]}},
{"typ": "nit", "engine": "motor", "mk": {"fz": [["T", 0, True, "B"]]}},
{"typ": "nit", "engine": "kandidat=x", "mk": {"fz": [["T", 0, False, "B"]]}},
{"typ": "reg", "engine": "motor", "mk": {"fz": [["R", 5, False, "B"]]}}, {"typ": "reg", "engine": "motor"}]
self.assertEqual(R.sim_folds(zeilen, "motor"), {("nit", 2, 0.45): [2, 3], ("reg", 3, 99.0): [0, 1]})
def test_tafel_lesen_nur_das_limit(self):
text = "# x\nZ 0.02 1 2 0.45 8 35\nZ 0.02 1 2 0.85 49 97\nZ 0.05 1 2 0.45 0 2\n"
self.assertEqual(R.tafel(text.splitlines(), 0.02), {(1, 2, 0.45): (8, 35), (1, 2, 0.85): (49, 97)})
class Wilson(unittest.TestCase):
def test_intervall(self):
lo, hi = R.wilson(50, 100)
self.assertAlmostEqual(lo, 0.4038, places=3); self.assertAlmostEqual(hi, 0.5962, places=3)
self.assertEqual(R.wilson(0, 0), (0.0, 1.0))
def test_intervall_am_rand_ist_nicht_um_p_zentriert(self):
lo, hi = R.wilson(0, 10)
self.assertAlmostEqual(lo, 0.0, places=9); self.assertAlmostEqual(hi, 0.2775, places=3)
lo, hi = R.wilson(10, 10)
self.assertAlmostEqual(lo, 0.7225, places=3); self.assertAlmostEqual(hi, 1.0, places=9)
if __name__ == "__main__":
unittest.main()