Skip to content

Commit f46a2ed

Browse files
committed
removed test_nash_behavior_solver_no_subtests_only_profile and re-incorporated cases with ids test_enumpoly_behavior_1{a,b}
1 parent 0c69a08 commit f46a2ed

File tree

1 file changed

+28
-60
lines changed

1 file changed

+28
-60
lines changed

tests/test_nash.py

Lines changed: 28 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1971,7 +1971,34 @@ def test_nash_strategy_solver_w_start(test_case: EquilibriumTestCaseWithStart, s
19711971
prob_tol=TOL,
19721972
),
19731973
marks=pytest.mark.nash_enumpoly_behavior,
1974-
id="test_enumpoly_behavior_01",
1974+
id="test_enumpoly_behavior_0",
1975+
),
1976+
# 2-player non-zero-sum games
1977+
pytest.param(
1978+
EquilibriumTestCase(
1979+
factory=games.create_one_shot_trust_efg,
1980+
solver=functools.partial(gbt.nash.enumpoly_solve, stop_after=None),
1981+
expected=[
1982+
[[d(0, 1)], [d(0, 1)]],
1983+
],
1984+
regret_tol=TOL,
1985+
prob_tol=TOL,
1986+
),
1987+
marks=pytest.mark.nash_enumpoly_behavior,
1988+
id="test_enumpoly_behavior_1a",
1989+
),
1990+
pytest.param(
1991+
EquilibriumTestCase(
1992+
factory=functools.partial(games.create_one_shot_trust_efg, unique_NE_variant=True),
1993+
solver=functools.partial(gbt.nash.enumpoly_solve, stop_after=None),
1994+
expected=[
1995+
[[d(1, 0)], [d(0, 1)]],
1996+
],
1997+
regret_tol=TOL,
1998+
prob_tol=TOL,
1999+
),
2000+
marks=pytest.mark.nash_enumpoly_behavior,
2001+
id="test_enumpoly_behavior_1b",
19752002
),
19762003
pytest.param(
19772004
EquilibriumTestCase(
@@ -2173,65 +2200,6 @@ def test_nash_behavior_solver(test_case: EquilibriumTestCase, subtests) -> None:
21732200
assert abs(eq[action] - expected[action]) <= test_case.prob_tol
21742201

21752202

2176-
##################################################################################################
2177-
# BEHAVIOR SOLVER WITHOUT SUBTESTS -- TEMP FOR ISSUE 660
2178-
##################################################################################################
2179-
2180-
ENUMPOLY_ISSUE_660_CASES = [
2181-
# 2-player non-zero-sum games
2182-
pytest.param(
2183-
EquilibriumTestCase(
2184-
factory=games.create_one_shot_trust_efg,
2185-
solver=functools.partial(gbt.nash.enumpoly_solve, stop_after=None),
2186-
expected=[
2187-
[[d(0, 1)], [d("1/2", "1/2")]],
2188-
[[d(0, 1)], [d(0, 1)]],
2189-
# second entry assumes we extend to Nash using only pure behaviors
2190-
# currently we get [[0, 1]], [[0, 0]]] as a second eq
2191-
],
2192-
regret_tol=TOL,
2193-
prob_tol=TOL,
2194-
),
2195-
marks=[
2196-
pytest.mark.nash_enumpoly_behavior,
2197-
pytest.mark.xfail(reason="Problem with enumpoly, as per issue #660"),
2198-
],
2199-
id="enumpoly_one_shot_trust_issue_660",
2200-
),
2201-
pytest.param(
2202-
EquilibriumTestCase(
2203-
factory=functools.partial(games.create_one_shot_trust_efg, unique_NE_variant=True),
2204-
solver=functools.partial(gbt.nash.enumpoly_solve, stop_after=None),
2205-
expected=[
2206-
[[[d(1, 0)], [d(0, 1)]]],
2207-
# currently we get [d(0, 1)], [d(0, 0)]] as a second eq
2208-
],
2209-
regret_tol=TOL,
2210-
prob_tol=TOL,
2211-
),
2212-
marks=[
2213-
pytest.mark.nash_enumpoly_behavior,
2214-
pytest.mark.xfail(reason="Problem with enumpoly, as per issue #660"),
2215-
],
2216-
id="enumpoly_one_shot_trust_unique_NE_issue_660",
2217-
),
2218-
]
2219-
2220-
2221-
@pytest.mark.nash
2222-
@pytest.mark.parametrize("test_case", ENUMPOLY_ISSUE_660_CASES, ids=lambda c: c.label)
2223-
def test_nash_behavior_solver_no_subtests_only_profile(test_case: EquilibriumTestCase) -> None:
2224-
"""TEMP: to be included with test_nash_behavior_solver when 660 is resolved."""
2225-
game = test_case.factory()
2226-
result = test_case.solver(game)
2227-
assert len(result.equilibria) == len(test_case.expected)
2228-
for eq, exp in zip(result.equilibria, test_case.expected, strict=True):
2229-
expected = game.mixed_behavior_profile(rational=True, data=exp)
2230-
for player in game.players:
2231-
for action in player.actions:
2232-
assert abs(eq[action] - expected[action]) <= test_case.prob_tol
2233-
2234-
22352203
##################################################################################################
22362204
# BEHVAIOR SOLVER -- UNORDERED
22372205
##################################################################################################

0 commit comments

Comments
 (0)