@@ -34,7 +34,7 @@ def _set_action_probs(profile: gbt.MixedBehaviorProfile, probs: list, rational_f
3434 (games .create_stripped_down_poker_efg (), 1 , "1/4" , True )
3535 ]
3636)
37- def test_payoff_reference (game : gbt .Game , player_idx : int , payoff : typing . Union [ str , float ] ,
37+ def test_payoff_reference (game : gbt .Game , player_idx : int , payoff : str | float ,
3838 rational_flag : bool ):
3939 profile = game .mixed_behavior_profile (rational = rational_flag )
4040 payoff = gbt .Rational (payoff ) if rational_flag else payoff
@@ -55,7 +55,7 @@ def test_payoff_reference(game: gbt.Game, player_idx: int, payoff: typing.Union[
5555 (games .create_stripped_down_poker_efg (), "Bob" , "1/4" , True ),
5656 ]
5757)
58- def test_payoff_by_label_reference (game : gbt .Game , label : str , payoff : typing . Union [ str , float ] ,
58+ def test_payoff_by_label_reference (game : gbt .Game , label : str , payoff : str | float ,
5959 rational_flag : bool ):
6060 profile = game .mixed_behavior_profile (rational = rational_flag )
6161 payoff = gbt .Rational (payoff ) if rational_flag else payoff
@@ -130,7 +130,7 @@ def test_is_defined_at_by_label(game: gbt.Game, label: str, rational_flag: bool)
130130def test_profile_indexing_by_player_infoset_action_idx_reference (game : gbt .Game , player_idx : int ,
131131 infoset_idx : int ,
132132 action_idx : int ,
133- prob : typing . Union [ str , float ] ,
133+ prob : str | float ,
134134 rational_flag : bool ):
135135 profile = game .mixed_behavior_profile (rational = rational_flag )
136136 action = game .players [player_idx ].infosets [infoset_idx ].actions [action_idx ]
@@ -157,7 +157,7 @@ def test_profile_indexing_by_player_infoset_action_idx_reference(game: gbt.Game,
157157 ]
158158)
159159def test_profile_indexing_by_action_label_reference (game : gbt .Game , action_label : str ,
160- prob : typing . Union [ str , float ] ,
160+ prob : str | float ,
161161 rational_flag : bool ):
162162 """Here we only use the action label, which are all valid"""
163163 profile = game .mixed_behavior_profile (rational = rational_flag )
@@ -181,7 +181,7 @@ def test_profile_indexing_by_action_label_reference(game: gbt.Game, action_label
181181)
182182def test_profile_indexing_by_invalid_action_label (game : gbt .Game , action_label : str ,
183183 rational_flag : bool ,
184- error : typing . Union [ ValueError , KeyError ] ):
184+ error : ValueError | KeyError ):
185185 """Test that we get a KeyError for a missing label, and a ValueError for an ambigiuous label
186186 """
187187 with pytest .raises (error ):
@@ -225,7 +225,7 @@ def test_profile_indexing_by_invalid_infoset_label(rational_flag: bool):
225225def test_profile_indexing_by_infoset_and_action_labels_reference (game : gbt .Game ,
226226 infoset_label : str ,
227227 action_label : str ,
228- prob : typing . Union [ str , float ] ,
228+ prob : str | float ,
229229 rational_flag : bool ):
230230 """Here we use the infoset label and action label, with some examples where the action label
231231 alone throws a ValueError (checked in a separate test)
@@ -255,7 +255,7 @@ def test_profile_indexing_by_player_infoset_action_labels_reference(game: gbt.Ga
255255 player_label : str ,
256256 infoset_label : str ,
257257 action_label : str ,
258- prob : typing . Union [ str , float ] ,
258+ prob : str | float ,
259259 rational_flag : bool ):
260260 """Here we use the infoset label and action label, with some examples where the action label
261261 alone throws a ValueError (checked in a separate test)
@@ -443,7 +443,7 @@ def test_profile_indexing_by_player_label_reference(game: gbt.Game, player_label
443443 (games .create_stripped_down_poker_efg (), 5 , "6/10" , True ),
444444 ]
445445)
446- def test_set_probabilities_action (game : gbt .Game , action_idx : int , prob : typing . Union [ str , float ] ,
446+ def test_set_probabilities_action (game : gbt .Game , action_idx : int , prob : str | float ,
447447 rational_flag : bool ):
448448 """Test to set probabilities of actions by action index"""
449449 profile = game .mixed_behavior_profile (rational = rational_flag )
@@ -472,7 +472,7 @@ def test_set_probabilities_action(game: gbt.Game, action_idx: int, prob: typing.
472472 ]
473473)
474474def test_set_probabilities_action_by_label (game : gbt .Game , label : str ,
475- prob : typing . Union [ str , float ] , rational_flag : bool ):
475+ prob : str | float , rational_flag : bool ):
476476 profile = game .mixed_behavior_profile (rational = rational_flag )
477477 prob = gbt .Rational (prob ) if rational_flag else prob
478478 profile [label ] = prob
@@ -634,7 +634,7 @@ def test_set_probabilities_player_by_label(game: gbt.Game, player_label: str, be
634634 (games .create_stripped_down_poker_efg (), 10 , 0.25 , False )]
635635)
636636def test_realiz_prob_nodes_reference (game : gbt .Game , node_idx : int ,
637- realiz_prob : typing . Union [ str , float ] , rational_flag : bool ):
637+ realiz_prob : str | float , rational_flag : bool ):
638638 profile = game .mixed_behavior_profile (rational = rational_flag )
639639 realiz_prob = (gbt .Rational (realiz_prob ) if rational_flag else realiz_prob )
640640 node = list (game .nodes )[node_idx ]
@@ -658,7 +658,7 @@ def test_realiz_prob_nodes_reference(game: gbt.Game, node_idx: int,
658658 ]
659659)
660660def test_infoset_prob_reference (game : gbt .Game , player_idx : int , infoset_idx : int ,
661- prob : typing . Union [ str , float ] , rational_flag : bool ):
661+ prob : str | float , rational_flag : bool ):
662662 profile = game .mixed_behavior_profile (rational = rational_flag )
663663 ip = profile .infoset_prob (game .players [player_idx ].infosets [infoset_idx ])
664664 assert ip == (gbt .Rational (prob ) if rational_flag else prob )
@@ -681,7 +681,7 @@ def test_infoset_prob_reference(game: gbt.Game, player_idx: int, infoset_idx: in
681681 ]
682682)
683683def test_infoset_prob_by_label_reference (game : gbt .Game , label : str ,
684- prob : typing . Union [ str , float ] , rational_flag : bool ):
684+ prob : str | float , rational_flag : bool ):
685685 profile = game .mixed_behavior_profile (rational = rational_flag )
686686 assert profile .infoset_prob (label ) == (gbt .Rational (prob ) if rational_flag else prob )
687687
@@ -703,7 +703,7 @@ def test_infoset_prob_by_label_reference(game: gbt.Game, label: str,
703703 ]
704704)
705705def test_infoset_payoff_reference (game : gbt .Game , player_idx : int , infoset_idx : int ,
706- payoff : typing . Union [ str , float ] , rational_flag : bool ):
706+ payoff : str | float , rational_flag : bool ):
707707 profile = game .mixed_behavior_profile (rational = rational_flag )
708708 iv = profile .infoset_value (game .players [player_idx ].infosets [infoset_idx ])
709709 assert iv == (gbt .Rational (payoff ) if rational_flag else payoff )
@@ -726,7 +726,7 @@ def test_infoset_payoff_reference(game: gbt.Game, player_idx: int, infoset_idx:
726726 ]
727727)
728728def test_infoset_payoff_by_label_reference (game : gbt .Game , label : str ,
729- payoff : typing . Union [ str , float ] , rational_flag : bool ):
729+ payoff : str | float , rational_flag : bool ):
730730 profile = game .mixed_behavior_profile (rational = rational_flag )
731731 assert profile .infoset_value (label ) == (gbt .Rational (payoff ) if rational_flag else payoff )
732732
@@ -761,7 +761,7 @@ def test_infoset_payoff_by_label_reference(game: gbt.Game, label: str,
761761 ]
762762)
763763def test_action_payoff_reference (game : gbt .Game , player_idx : int , infoset_idx : int ,
764- action_idx : int , payoff : typing . Union [ str , float ] ,
764+ action_idx : int , payoff : str | float ,
765765 rational_flag : bool ):
766766 profile = game .mixed_behavior_profile (rational = rational_flag )
767767 av = profile .action_value (game .players [player_idx ].infosets [infoset_idx ].actions [action_idx ])
@@ -787,7 +787,7 @@ def test_action_payoff_reference(game: gbt.Game, player_idx: int, infoset_idx: i
787787 ]
788788)
789789def test_action_value_by_label_reference (game : gbt .Game , label : str ,
790- payoff : typing . Union [ str , float ] , rational_flag : bool ):
790+ payoff : str | float , rational_flag : bool ):
791791 profile = game .mixed_behavior_profile (rational = rational_flag )
792792 assert profile .action_value (label ) == (gbt .Rational (payoff ) if rational_flag else payoff )
793793
@@ -859,8 +859,8 @@ def test_regret_consistency(game: gbt.Game, rational_flag: bool):
859859 ]
860860)
861861def test_regret_reference (game : gbt .Game , player_idx : int , infoset_idx : int , action_idx : int ,
862- action_probs : typing . Union [ None , list ] , rational_flag : bool ,
863- tol : typing . Union [ gbt .Rational , float ] , value : typing . Union [ str , float ] ):
862+ action_probs : None | list , rational_flag : bool ,
863+ tol : gbt .Rational | float , value : str | float ):
864864 action = game .players [player_idx ].infosets [infoset_idx ].actions [action_idx ]
865865 profile = game .mixed_behavior_profile (rational = rational_flag )
866866 if action_probs :
@@ -941,8 +941,8 @@ def test_node_value_consistency(game: gbt.Game, rational_flag: bool):
941941 (games .create_stripped_down_poker_efg (), [1.0 , 0.0 , 1.0 , 0.0 , 1.0 , 0.0 ], False , 1.0 ),
942942 ]
943943)
944- def test_liap_value_reference (game : gbt .Game , action_probs : typing . Union [ None , list ] ,
945- rational_flag : bool , expected_value : typing . Union [ str , float ] ):
944+ def test_liap_value_reference (game : gbt .Game , action_probs : None | list ,
945+ rational_flag : bool , expected_value : str | float ):
946946 """Tests liap_value under profile given by action_probs
947947 (which will be uniform if action_probs is None)
948948 """
@@ -985,9 +985,9 @@ def test_liap_value_reference(game: gbt.Game, action_probs: typing.Union[None, l
985985 2 , 1 , "2/7" , True ),
986986 ]
987987 )
988- def test_node_belief_reference (game : gbt .Game , tol : typing . Union [ gbt .Rational , float ] ,
988+ def test_node_belief_reference (game : gbt .Game , tol : gbt .Rational | float ,
989989 probs : list , infoset_idx : int , member_idx : int ,
990- value : typing . Union [ str , float ] , rational_flag : bool ):
990+ value : str | float , rational_flag : bool ):
991991 profile = game .mixed_behavior_profile (rational = rational_flag )
992992 _set_action_probs (profile , probs , rational_flag )
993993 node = game .infosets [infoset_idx ].members [member_idx ]
@@ -1181,7 +1181,7 @@ def test_specific_profile(game: gbt.Game, rational_flag: bool, data: list):
11811181 for each player over his actions.
11821182 """
11831183 profile = game .mixed_behavior_profile (rational = rational_flag , data = data )
1184- for (action , prob ) in zip (game .actions , [k for i in data for j in i for k in j ]):
1184+ for (action , prob ) in zip (game .actions , [k for i in data for j in i for k in j ], strict = True ):
11851185 assert profile [action ] == (gbt .Rational (prob ) if rational_flag else prob )
11861186
11871187
0 commit comments