From d16e52557908991f1241c0f9b19b14feb65d6579 Mon Sep 17 00:00:00 2001 From: satyam yadav Date: Sat, 21 Feb 2026 12:53:27 +0530 Subject: [PATCH] Update test_behav.py --- tests/test_behav.py | 47 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/tests/test_behav.py b/tests/test_behav.py index c3468ef0c..dcd5ace49 100644 --- a/tests/test_behav.py +++ b/tests/test_behav.py @@ -1357,3 +1357,50 @@ def test_tree_representation_error(game: gbt.Game, rational_flag: bool, data: li """ with pytest.raises(gbt.UndefinedOperationError): game.mixed_behavior_profile(rational=rational_flag, data=data) + +@pytest.mark.parametrize( + "game,rational_flag", + [(games.create_mixed_behav_game_efg(), False), + (games.create_mixed_behav_game_efg(), True), + (games.create_stripped_down_poker_efg(), False), + (games.create_stripped_down_poker_efg(), True), + ] +) +def test_mixed_behavior_profile_max_regret(game: gbt.Game, rational_flag: bool): + """Test that max_regret executes without error and returns a valid non-negative number.""" + profile = game.mixed_behavior_profile(rational=rational_flag) + + # Calculate the standard max regret + regret = profile.max_regret() + + # Check type depending on the rational flag + if rational_flag: + assert isinstance(regret, gbt.Rational) + else: + assert isinstance(regret, float) + + assert regret >= 0 + + +@pytest.mark.parametrize( + "game,rational_flag", + [(games.create_mixed_behav_game_efg(), False), + (games.create_mixed_behav_game_efg(), True), + (games.create_stripped_down_poker_efg(), False), + (games.create_stripped_down_poker_efg(), True), + ] +) +def test_mixed_behavior_profile_agent_max_regret(game: gbt.Game, rational_flag: bool): + """Test that agent_max_regret executes without error and returns a valid non-negative number.""" + profile = game.mixed_behavior_profile(rational=rational_flag) + + # Calculate the agent max regret + agent_regret = profile.agent_max_regret() + + # Check type depending on the rational flag + if rational_flag: + assert isinstance(agent_regret, gbt.Rational) + else: + assert isinstance(agent_regret, float) + + assert agent_regret >= 0