File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1844,30 +1844,25 @@ class Game:
18441844 def sort_infosets(self ) -> None:
18451845 """Sort information sets into a standard order.
18461846
1847- When iterating the information sets of a player , the order in which information
1848- sets are visited may be dependent on the order of the operations used to build
1849- the extensive game. This function sorts each player's information sets into
1850- a standard order , namely , the order in which they are encountered in a depth-first
1851- traversal of the tree , and likewise sorts the members of each information set
1852- by the order in which they are encountered in a depth-first traversal.
1853-
1854- .. versionadded:: 16.4.0
1847+ .. deprecated:: 16.5.0
1848+ This operation is deprecated as efficient management of the iteration orders of
1849+ information sets and their members is now handled by the representation objects.
18551850
18561851 Raises
18571852 ------
18581853 UndefinedOperationError
18591854 If the game does not have a tree representation.
1860-
1861- See also
1862- --------
1863- Player.infosets
1864- Infoset.members
18651855 """
1856+ warnings.warn(
1857+ "sort_infosets() is deprecated; This operation is now done automatically when"
1858+ " required. "
1859+ "This function will be removed in a future release.",
1860+ FutureWarning
1861+ )
18661862 if not self.is_tree:
18671863 raise UndefinedOperationError(
18681864 "Operation only defined for games with a tree representation"
18691865 )
1870- pass
18711866
18721867 def add_player(self , label: str = " " ) -> Player:
18731868 """Add a new player to the game.
Original file line number Diff line number Diff line change @@ -206,19 +206,13 @@ class Infoset:
206206 def members(self ) -> InfosetMembers:
207207 """The set of nodes which are members of the information set.
208208
209- The order in which members are iterated is dependent on the order of
210- operations used to define the game. A standard ordering , in which members
211- are iterated in the order encountered in a depth-first traversal of the tree ,
212- can be obtained by calling `Game.sort_infosets` on the game after construction.
209+ The iteration order of information set members is the order in which they
210+ are encountered in the pre-order depth first traversal of the game tree.
213211
214- .. versionchanged:: 16.4.0
215- The ordering of members is now dependent on the order of operations;
216- previously , members sets were (expensively ) re-sorted after every change
217- to the game tree.
212+ .. versionchanged:: 16.5.0
213+ It is no longer necessary to call `Game.sort_infosets` to standardise
214+ iteration order.
218215
219- See also
220- --------
221- Game.sort_infosets
222216 """
223217 return InfosetMembers.wrap(self.infoset )
224218
Original file line number Diff line number Diff line change @@ -218,24 +218,17 @@ class Player:
218218 def infosets(self ) -> PlayerInfosets:
219219 """Returns the set of information sets at which the player has the decision.
220220
221- The order in which information sets are iterated is dependent on the order of
222- operations used to define the game. A standard ordering , in which information
223- sets are iterated in the order encountered in a depth-first traversal of the tree ,
224- can be obtained by calling `Game.sort_infosets` on the game after construction.
221+ The iteration order of information sets is the order in which they
222+ are encountered in the pre-order depth first traversal of the game tree.
225223
226- .. versionchanged:: 16.4.0
227- The ordering of information sets is now dependent on the order of operations;
228- previously , information sets were (expensively ) re-sorted after every change
229- to the game tree.
224+ .. versionchanged:: 16.5.0
225+ It is no longer necessary to call `Game.sort_infosets` to standardise
226+ iteration order.
230227
231228 Raises
232229 ------
233230 UndefinedOperationError
234231 If the game does not have a tree representation.
235-
236- See also
237- --------
238- Game.sort_infosets
239232 """
240233 if not self.game.is_tree:
241234 raise UndefinedOperationError(
Original file line number Diff line number Diff line change 55from abc import ABC , abstractmethod
66
77import numpy as np
8+ import pytest
89
910import pygambit as gbt
1011
@@ -651,7 +652,8 @@ def create_kuhn_poker_efg(nonterm_outcomes: bool = False) -> gbt.Game:
651652 g = _create_kuhn_poker_efg_only_term_outcomes ()
652653
653654 # Ensure infosets are in the same order as if game was written to efg and read back in
654- g .sort_infosets ()
655+ with pytest .warns (FutureWarning ):
656+ g .sort_infosets ()
655657 return g
656658
657659
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ def test_strategic_game_nodes():
4343
4444def test_strategic_game_sort_infosets ():
4545 game = gbt .Game .new_table ([2 , 2 ])
46- with pytest .raises (gbt .UndefinedOperationError ):
46+ with pytest .warns ( FutureWarning ), pytest . raises (gbt .UndefinedOperationError ):
4747 _ = game .sort_infosets ()
4848
4949
You can’t perform that action at this time.
0 commit comments