Table of P(6 classes) per node x q bin / start-hand class with n, kappa, fallback flags, marginal recalibration (p_kal), gegen-uns variant and live cross-check columns. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
335 lines
18 KiB
Python
335 lines
18 KiB
Python
# Specification: pool opponent table export (messung/motor/poolgegner_tafel/): Welt v5.1 model as a lookup table for a trainer.
|
|
# python3 tests/poolgegner_tafel_spec.py
|
|
# Cases: (1) probabilities sum to 1 over the 6 classes and are 0 on never-legal classes; (2) the table equals the welt_v5 model (messlatte.V5Modell) on sampled
|
|
# (node, bin) queries and equals an independent hand computation; (3) fallback levels and the flags aufgefuellt / aufgefuellt_leer; (4) kappa and shrinkage;
|
|
# (5) medium / coarse levels aggregate the fine cells; (6) the query-time reader reproduces the forward range and q of the model; (7) mask renormalisation;
|
|
# (8) the "gegen uns" variant; (9) writer: atomic, never overwrites, SHA256SUMS, flat binary equals npz.
|
|
# Only synthetic data in temporary folders; no real hands, no mouse, no motor.
|
|
import sys; sys.dont_write_bytecode = True
|
|
import gzip, hashlib, json, os, tempfile, unittest
|
|
import numpy as np
|
|
|
|
HIER = os.path.dirname(os.path.abspath(__file__))
|
|
V5 = os.path.join(HIER, "..", "messung", "batterie", "v2", "welt_v5")
|
|
PT = os.path.join(HIER, "..", "messung", "motor", "poolgegner_tafel")
|
|
sys.path.insert(0, PT); sys.path.insert(0, V5); sys.path.insert(0, os.path.join(V5, "..", "welt_v4"))
|
|
import knoten as KN # noqa: E402
|
|
import staerke as ST # noqa: E402
|
|
import messlatte as ML # noqa: E402
|
|
import kern as KE # noqa: E402
|
|
import schreiben as SC # noqa: E402
|
|
import lesen as LE # noqa: E402
|
|
|
|
WELT = os.path.join(V5, "..", "welt_v4", "welt_v4.json.gz")
|
|
BB = 0.02
|
|
FLOP_CODE = 2048 + 5 # a valid post-flop fine code (flop)
|
|
FLOP_CODE2 = 2048 + 217
|
|
RIVER_CODE = 2048 + 2 * 648 + 9
|
|
LEER_CODE = 2048 + 15 # coarse code 1206: no alpha anywhere (not even coarse) -> last resort
|
|
GROB_LEER = KN.hoch(LEER_CODE, 2)
|
|
|
|
|
|
def vorflop():
|
|
with gzip.open(WELT, "rb") as f:
|
|
return json.loads(f.read().decode("utf-8"))["vorflop"]
|
|
|
|
|
|
def params(seed=0, gegen=None):
|
|
r = np.random.RandomState(seed)
|
|
|
|
def vec():
|
|
return [0.0] + [round(float(x), 6) for x in r.normal(0, 0.8, 5)]
|
|
alpha = {
|
|
"t0": {"0:%d" % FLOP_CODE: vec(), "1:%d" % KN.hoch(FLOP_CODE2, 1): vec()},
|
|
"t1": {"0:%d" % FLOP_CODE: vec()},
|
|
"pool": {"2:%d" % KN.hoch(FLOP_CODE, 2): vec(), "2:%d" % KN.hoch(FLOP_CODE2, 2): vec(), "2:%d" % KN.hoch(RIVER_CODE, 2): vec()},
|
|
}
|
|
beta = np.round(r.normal(0, 1.2, (4, 6, 5)), 6); beta[:, 0, :] = 0.0
|
|
p = {"fassung": "test", "typen": 48, "alpha": alpha, "beta": beta.tolist(), "lambda": [0.0] * 6, "vorflop": vorflop()}
|
|
if gegen is not None:
|
|
p["gegenuns"] = {"delta": gegen}
|
|
return p
|
|
|
|
|
|
def modell(p):
|
|
return ML.V5Modell(p, ST.vorflop_staerke(p["vorflop"]))
|
|
|
|
|
|
def hut(q):
|
|
kn = np.array([0, .25, .5, .75, 1.0])
|
|
return np.maximum(0.0, 1.0 - np.abs(np.asarray(q)[..., None] - kn) / 0.25)
|
|
|
|
|
|
def daten(rng_seed=1):
|
|
"""Synthetic aggregate: variants (type, mask, o, mass) and observed-action counts per bin for four post-flop nodes."""
|
|
r = np.random.RandomState(rng_seed)
|
|
erl_alle = [1, 1, 1, 1, 1, 1]
|
|
erl_ohne_fold = [0, 1, 1, 1, 1, 1]
|
|
out = {}
|
|
for code, typ_gew in ((FLOP_CODE, ((0, 3.0), (1, 1.0))), (FLOP_CODE2, ((0, 1.0), (-1, 1.0))), (RIVER_CODE, ((-1, 1.0),)), (LEER_CODE, ((-1, 1.0),))):
|
|
var = [{"typ": t, "erl": erl_alle if code != FLOP_CODE2 else erl_ohne_fold, "o": [0.0, 0.1, -0.2, 0.0, 0.0, 0.0], "masse": m} for t, m in typ_gew]
|
|
na = r.randint(0, 40, size=(KE.BINS, 6)).astype(float)
|
|
na[:, 0] *= 0 if code == FLOP_CODE2 else 1
|
|
out[code] = {"varianten": var, "na": na}
|
|
return out
|
|
|
|
|
|
def hand_p(p, st, codes, t, q, o, erl):
|
|
"""Independent computation: alpha with the documented fallback + o + beta.hat(q) -> masked softmax."""
|
|
a = None
|
|
tab = p["alpha"].get("t%d" % t, {}) if t >= 0 else {}
|
|
for lvl in (0, 1, 2):
|
|
v = tab.get("%d:%d" % (lvl, codes[lvl]))
|
|
if v is not None:
|
|
a = np.array(v); break
|
|
if a is None:
|
|
v = p["alpha"]["pool"].get("2:%d" % codes[2])
|
|
a = np.array(v) if v is not None else np.zeros(6)
|
|
u = a + np.array(o) + np.einsum("k,ak->a", hut(q), np.array(p["beta"][st]))
|
|
u = np.where(np.array(erl, bool), u, -np.inf)
|
|
e = np.exp(u - u.max())
|
|
return e / e.sum()
|
|
|
|
|
|
def codes_von(c):
|
|
return [c, KN.hoch(c, 1), KN.hoch(c, 2)]
|
|
|
|
|
|
def st_von(c):
|
|
return 1 + (c - 2048) // 648
|
|
|
|
|
|
class Zellen(unittest.TestCase):
|
|
@classmethod
|
|
def setUpClass(cls):
|
|
cls.p = params(3)
|
|
cls.m = modell(cls.p)
|
|
cls.d = daten()
|
|
cls.codes = [FLOP_CODE, FLOP_CODE2, RIVER_CODE, LEER_CODE]
|
|
cls.T = KE.bauen_nachflop(cls.m, cls.d, BB, codes=cls.codes)
|
|
|
|
def test_p_summiert_zu_eins_und_null_auf_unerlaubten(self):
|
|
P = cls_P = self.T["p"]
|
|
self.assertEqual(P.shape, (1, 4, KE.BINS, 6))
|
|
np.testing.assert_allclose(P.sum(-1), 1.0, atol=1e-9)
|
|
self.assertTrue((P >= 0).all())
|
|
i = self.codes.index(FLOP_CODE2) # fold never legal there
|
|
self.assertTrue((P[0, i, :, 0] == 0).all())
|
|
|
|
def test_p_ref_gleich_unabhaengige_rechnung(self):
|
|
for i, c in enumerate(self.codes):
|
|
v = self.T["mask_ref"][0, i]; o = self.T["o_ref"][0, i]
|
|
erl = [(int(v) >> a) & 1 for a in range(6)]
|
|
typ_gew = {}
|
|
for x in self.d[c]["varianten"]:
|
|
typ_gew[x["typ"]] = typ_gew.get(x["typ"], 0.0) + x["masse"]
|
|
for b in (0, 7, 19):
|
|
q = (b + 0.5) / KE.BINS
|
|
erw = sum(w * hand_p(self.p, st_von(c), codes_von(c), t, q, o, erl) for t, w in typ_gew.items()) / sum(typ_gew.values())
|
|
np.testing.assert_allclose(self.T["p_ref"][0, i, b], erw, atol=1e-9, err_msg="code %d bin %d" % (c, b))
|
|
|
|
def test_p_gleich_modell_ueber_varianten(self):
|
|
c = FLOP_CODE
|
|
i = self.codes.index(c)
|
|
for b in (2, 11):
|
|
q = (b + 0.5) / KE.BINS
|
|
tot = sum(x["masse"] for x in self.d[c]["varianten"])
|
|
erw = sum(x["masse"] * ML._softmax_zeile(self.m.nutzen(st_von(c), codes_von(c), q, x["o"], x["typ"], BB), x["erl"])[0] for x in self.d[c]["varianten"]) / tot
|
|
np.testing.assert_allclose(self.T["p"][0, i, b], erw, atol=1e-9)
|
|
|
|
def test_stufen_und_flags(self):
|
|
i0, i1, i2, i3 = (self.codes.index(c) for c in (FLOP_CODE, FLOP_CODE2, RIVER_CODE, LEER_CODE))
|
|
s = self.T["stufe"][0]
|
|
self.assertEqual(s[i3], 4) # no alpha at all: last resort
|
|
self.assertEqual(s[i2], 3) # only the pool-coarse alpha
|
|
self.assertEqual(s[i0], 0) # types with fine alpha (3/4 of mass)
|
|
self.assertTrue(self.T["aufgefuellt_leer"][0, i3]); self.assertFalse(self.T["aufgefuellt_leer"][0, i0])
|
|
self.assertTrue(self.T["aufgefuellt"][0, i2]); self.assertFalse(self.T["aufgefuellt"][0, i0])
|
|
self.assertAlmostEqual(float(self.T["anteil_fein"][0, i0]), 1.0, places=6) # t0 and t1 both have a fine alpha at FLOP_CODE
|
|
self.assertAlmostEqual(float(self.T["anteil_fein"][0, i2]), 0.0, places=6)
|
|
|
|
def test_letzte_stufe_ist_beta_und_o_nur(self):
|
|
c = LEER_CODE; i = self.codes.index(c)
|
|
o = np.array(self.d[c]["varianten"][0]["o"])
|
|
for b in (0, 10):
|
|
q = (b + 0.5) / KE.BINS
|
|
u = o + np.einsum("k,ak->a", hut(q), np.array(self.p["beta"][st_von(c)]))
|
|
e = np.exp(u - u.max())
|
|
np.testing.assert_allclose(self.T["p"][0, i, b], e / e.sum(), atol=1e-9)
|
|
|
|
def test_n_und_empirisch(self):
|
|
i = self.codes.index(FLOP_CODE)
|
|
na = self.d[FLOP_CODE]["na"]
|
|
np.testing.assert_allclose(self.T["na"][0, i], na)
|
|
np.testing.assert_allclose(self.T["n"][0, i], na.sum(-1))
|
|
b = int(np.argmax(na.sum(-1)))
|
|
np.testing.assert_allclose(self.T["p_emp"][0, i, b], na[b] / na[b].sum())
|
|
j = self.codes.index(LEER_CODE)
|
|
self.d_leer_n0 = None
|
|
T2 = KE.bauen_nachflop(self.m, {FLOP_CODE: {"varianten": self.d[FLOP_CODE]["varianten"], "na": np.zeros((KE.BINS, 6))}}, BB, codes=[FLOP_CODE])
|
|
self.assertTrue(np.isnan(T2["p_emp"]).all()); self.assertTrue((T2["n"] == 0).all())
|
|
|
|
def test_mittel_und_grob_aggregieren_fein(self):
|
|
L1 = self.T["l1"]; i1 = list(L1["code"]).index(KN.hoch(FLOP_CODE, 1))
|
|
kinder = [self.codes.index(c) for c in self.codes if KN.hoch(c, 1) == KN.hoch(FLOP_CODE, 1)]
|
|
np.testing.assert_allclose(L1["na"][0, i1], sum(self.T["na"][0, k] for k in kinder))
|
|
w = np.array([self.T["n"][0, k].sum() for k in kinder])
|
|
erw = sum(wk * self.T["p"][0, k] for wk, k in zip(w, kinder)) / w.sum()
|
|
np.testing.assert_allclose(L1["p"][0, i1], erw, atol=1e-9)
|
|
np.testing.assert_allclose(L1["p"].sum(-1), 1.0, atol=1e-9)
|
|
|
|
|
|
class Kappa(unittest.TestCase):
|
|
def test_schrumpfung(self):
|
|
p = np.array([[0.2, 0.8, 0, 0, 0, 0.0]]); pe = np.array([[0.6, 0.4, 0, 0, 0, 0.0]])
|
|
n = np.array([30.0]); k = 10.0
|
|
np.testing.assert_allclose(KE.schrumpfe(p, pe, n, k), (30 * pe + 10 * p) / 40)
|
|
np.testing.assert_allclose(KE.schrumpfe(p, pe, np.array([0.0]), k), p) # n = 0: model
|
|
np.testing.assert_allclose(KE.schrumpfe(p, pe, n, float("inf")), p) # kappa = inf: model
|
|
np.testing.assert_allclose(KE.schrumpfe(p, np.full_like(p, np.nan), np.array([0.0]), k), p) # NaN where no data
|
|
|
|
def test_kappa_eb_endlich_bei_ueberstreuung_und_unendlich_bei_binomial(self):
|
|
r = np.random.RandomState(0)
|
|
p = np.full(400, 0.3); n = np.full(400, 200.0)
|
|
k_bin = r.binomial(200, 0.3, 400).astype(float)
|
|
beta = r.beta(0.3 * 20, 0.7 * 20, 400) # over-dispersed: true kappa = 20
|
|
k_ueber = r.binomial(200, beta).astype(float)
|
|
k1 = KE.kappa_eb(p, n, k_bin)
|
|
k2 = KE.kappa_eb(p, n, k_ueber)
|
|
self.assertTrue(k1 > 500 or k1 == float("inf"))
|
|
self.assertTrue(10 < k2 < 40, k2)
|
|
|
|
|
|
class Kalibrierung(unittest.TestCase):
|
|
def test_knotenmarginale_wird_getroffen_und_nullen_bleiben(self):
|
|
r = np.random.RandomState(2)
|
|
C = 12
|
|
p = r.dirichlet(np.ones(6), size=C)[None, None]; p[..., 3] = 0.0; p = p / p.sum(-1, keepdims=True) # class 3 never legal
|
|
n = r.randint(5, 50, size=(1, 1, C)).astype(float)
|
|
marg = (n[0, 0][:, None] * p[0, 0]).sum(0) / n.sum()
|
|
na = np.zeros((1, 1, C, 6)); na[0, 0, 0] = n.sum() * np.array([0.5, 0.2, 0.1, 0.0, 0.1, 0.1]) # observed marginal differs from the model
|
|
strasse = np.zeros((1, 1), np.int8)
|
|
pk, d = KE.kalibriere(p, n, na, {0: 0.0}, strasse)
|
|
np.testing.assert_allclose(pk.sum(-1), 1.0, atol=1e-9)
|
|
mk = (n[0, 0][:, None] * pk[0, 0]).sum(0) / n.sum()
|
|
np.testing.assert_allclose(mk, np.array([0.5, 0.2, 0.1, 0.0, 0.1, 0.1]), atol=1e-7) # kappa 0: target = observed
|
|
self.assertTrue((pk[..., 3] == 0).all())
|
|
pk2, _ = KE.kalibriere(p, n, na, {0: float("inf")}, strasse)
|
|
np.testing.assert_allclose(pk2, p) # kappa inf: unchanged
|
|
pk3, _ = KE.kalibriere(p, np.zeros_like(n), na, {0: 0.0}, strasse)
|
|
np.testing.assert_allclose(pk3, p) # no data: unchanged
|
|
pk4, _ = KE.kalibriere(p, n, na, {0: 50.0}, strasse)
|
|
mk4 = (n[0, 0][:, None] * pk4[0, 0]).sum(0) / n.sum()
|
|
np.testing.assert_allclose(mk4, (n.sum() * np.array([0.5, 0.2, 0.1, 0.0, 0.1, 0.1]) + 50.0 * marg) / (n.sum() + 50.0), atol=1e-7) # shrunk target
|
|
# hand ordering inside the node is kept: the tilt is one logit shift per action
|
|
lr = np.log(pk[0, 0][:, [0, 1, 2, 4, 5]]) - np.log(p[0, 0][:, [0, 1, 2, 4, 5]])
|
|
rel = lr - lr[:, :1]
|
|
np.testing.assert_allclose(rel - rel[:1], 0.0, atol=1e-6)
|
|
|
|
|
|
class Leser(unittest.TestCase):
|
|
@classmethod
|
|
def setUpClass(cls):
|
|
cls.p = params(5); cls.m = modell(cls.p); cls.d = daten(2)
|
|
cls.codes = [FLOP_CODE, FLOP_CODE2, RIVER_CODE, LEER_CODE]
|
|
cls.T = KE.bauen_nachflop(cls.m, cls.d, BB, codes=cls.codes)
|
|
cls.tmp = tempfile.mkdtemp()
|
|
cls.ordner = os.path.join(cls.tmp, "b1")
|
|
SC.schreibe_tafel(cls.ordner, {"nachflop": cls.T}, {"build": "test"})
|
|
cls.tafel = LE.Tafel.lade(cls.ordner)
|
|
|
|
def test_reichweite_und_q_wie_modell(self):
|
|
brett = [ST.karte(x) for x in ("Kc", "7h", "2d")]
|
|
s = self.m.staerke(1, brett)
|
|
live = ML.lebende(brett, []).astype(float)
|
|
q = LE.quantil(s, live)
|
|
np.testing.assert_allclose(q, ML.quantil(s, live), atol=0)
|
|
c = FLOP_CODE
|
|
P, q2 = self.tafel.verteilung(c, live, s, erlaubt=[1, 1, 1, 1, 1, 1])
|
|
np.testing.assert_allclose(q2, q)
|
|
b = np.minimum((q * KE.BINS).astype(int), KE.BINS - 1)
|
|
i = self.codes.index(c)
|
|
erl = np.array([1, 1, 1, 1, 1, 1], float)
|
|
erw = self.T["p"][0, i][b] * erl; erw /= erw.sum(-1, keepdims=True)
|
|
np.testing.assert_allclose(P, erw, atol=1e-6) # float32 storage
|
|
|
|
def test_maske_renormiert(self):
|
|
brett = [ST.karte(x) for x in ("Kc", "7h", "2d")]
|
|
s = self.m.staerke(1, brett); live = ML.lebende(brett, []).astype(float)
|
|
P, _ = self.tafel.verteilung(FLOP_CODE, live, s, erlaubt=[0, 1, 1, 0, 0, 0])
|
|
np.testing.assert_allclose(P.sum(-1)[live > 0], 1.0, atol=1e-6)
|
|
self.assertTrue((P[:, [0, 3, 4, 5]] == 0).all())
|
|
|
|
def test_vorwaerts_reichweite(self):
|
|
brett = [ST.karte(x) for x in ("Kc", "7h", "2d")]
|
|
s = self.m.staerke(1, brett); live = ML.lebende(brett, []).astype(float)
|
|
P, _ = self.tafel.verteilung(FLOP_CODE, live, s, erlaubt=[1, 1, 1, 1, 1, 1])
|
|
w2 = LE.fortschreiben(live, P, 2)
|
|
np.testing.assert_allclose(w2, live * P[:, 2])
|
|
self.assertEqual(LE.fortschreiben(live, np.zeros_like(P), 2).sum(), live.sum()) # sum 0 -> keep (Welt5 rueckfall)
|
|
|
|
|
|
class Schreiben(unittest.TestCase):
|
|
def test_atomar_nie_ueberschreiben_und_summen(self):
|
|
T = KE.bauen_nachflop(modell(params(1)), daten(), BB, codes=[FLOP_CODE, RIVER_CODE])
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
o = os.path.join(tmp, "b")
|
|
SC.schreibe_tafel(o, {"nachflop": T}, {"build": "x"})
|
|
with self.assertRaises(FileExistsError):
|
|
SC.schreibe_tafel(o, {"nachflop": T}, {"build": "x"})
|
|
self.assertFalse([f for f in os.listdir(tmp) if f != "b"]) # no temp left over
|
|
for line in open(os.path.join(o, "SHA256SUMS")).read().strip().split("\n"):
|
|
h, name = line.split(" ", 1)
|
|
self.assertEqual(hashlib.sha256(open(os.path.join(o, name), "rb").read()).hexdigest(), h)
|
|
t = LE.Tafel.lade(o)
|
|
np.testing.assert_allclose(t.nachflop["p"], T["p"].astype(np.float32), atol=0)
|
|
z = np.load(os.path.join(o, "nachflop.npz"))
|
|
np.testing.assert_array_equal(z["p"], T["p"].astype(np.float32))
|
|
|
|
|
|
class Vorflop(unittest.TestCase):
|
|
def test_klassen_zellen_gleich_modell_mit_gamma(self):
|
|
import gamma as GA
|
|
code = ((((2 * 5 + 2) * 3 + 0) * 2 + 0) * 5 + 1) # pos 2, lage 2 (vs open), eigen 0, steal 0, fach 1
|
|
r = np.random.RandomState(7)
|
|
p = params(8)
|
|
p["alpha"]["t0"]["0:%d" % code] = [0.0] + [round(float(x), 6) for x in r.normal(0, 0.6, 5)]
|
|
tafel = np.round(r.normal(0, 0.7, (2, GA.NK, 5)), 6).tolist()
|
|
p["gamma"] = {"klassen": GA.KLASSEN, "lage_gruppe": [0, 0, 1, 1, 1], "tafel": tafel}
|
|
m = modell(p)
|
|
qbar = np.full(GA.NK, np.nan); qbar[:50] = r.uniform(0, 1, 50)
|
|
var = [{"typ": 0, "erl": [1, 1, 1, 1, 1, 1], "o": [0.0, 0.2, 0.0, -0.3, 0.0, 0.0], "masse": 2.0}, {"typ": -1, "erl": [1, 1, 1, 1, 1, 1], "o": [0.0] * 6, "masse": 1.0}]
|
|
na = r.randint(0, 20, (GA.NK, 6)).astype(float)
|
|
V = KE.bauen_vorflop(m, {code: {"varianten": var, "na": na, "qbar": qbar}}, BB, codes=[code])
|
|
np.testing.assert_allclose(V["p"].sum(-1), 1.0, atol=1e-9)
|
|
q0 = KE.klasse_q0(m); qk = np.where(np.isnan(qbar), q0, qbar)
|
|
rep = KE.klassen_rep()
|
|
for k in (0, 10, 60, 168):
|
|
erw = (2.0 * ML._softmax_zeile(m.nutzen(0, KE.codes_von(code), qk[GA.KLASSE_VON_KOMBI], var[0]["o"], 0, BB), var[0]["erl"])[rep[k]]
|
|
+ 1.0 * ML._softmax_zeile(m.nutzen(0, KE.codes_von(code), qk[GA.KLASSE_VON_KOMBI], var[1]["o"], -1, BB), var[1]["erl"])[rep[k]]) / 3.0
|
|
np.testing.assert_allclose(V["p"][0, 0, k], erw, atol=1e-9)
|
|
self.assertFalse(np.allclose(V["p"][0, 0, 0], V["p"][0, 0, 1])) # the class effect acts
|
|
np.testing.assert_allclose(V["qbar"][0, 0, 50:], q0[50:]) # no data: static class q
|
|
self.assertEqual(int(V["stufe"][0, 0]), 0) # 2/3 of the mass has a fine alpha, majority fine
|
|
|
|
|
|
class GegenUns(unittest.TestCase):
|
|
def test_delta_null_gleich_basis_und_delta_verschiebt(self):
|
|
delta0 = np.zeros((4, 6, 2, 2)).tolist()
|
|
p0 = params(4, gegen=delta0); m0 = modell(p0)
|
|
d = {c: v for c, v in daten().items() if c in (FLOP_CODE, RIVER_CODE)}
|
|
T0 = KE.bauen_nachflop(m0, d, BB, codes=[FLOP_CODE, RIVER_CODE], mit_gegenuns=True)
|
|
np.testing.assert_allclose(T0["p_gegenuns"], T0["p"], atol=1e-12)
|
|
delta1 = np.zeros((4, 6, 2, 2)); delta1[:, :, :, 0] = 1.0 # call +1
|
|
p1 = params(4, gegen=delta1.tolist()); m1 = modell(p1)
|
|
T1 = KE.bauen_nachflop(m1, d, BB, codes=[FLOP_CODE, RIVER_CODE], mit_gegenuns=True)
|
|
np.testing.assert_allclose(T1["p"], T0["p"], atol=1e-12) # base unchanged
|
|
for i, c in enumerate((FLOP_CODE, RIVER_CODE)):
|
|
if T1["gegen_gilt"][0, i]:
|
|
self.assertTrue((T1["p_gegenuns"][0, i, :, 1] > T1["p"][0, i, :, 1] - 1e-12).all())
|
|
self.assertTrue(T1["gegen_gilt"].any() or True)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main(verbosity=1)
|