File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -742,7 +742,16 @@ class Game:
742742 .. versionchanged:: 16.4
743743 Changed from a method ``nodes()`` to a property.
744744
745+ Raises
746+ ------
747+ UndefinedOperationError
748+ If the game does not have a tree representation.
745749 """
750+ if not self.is_tree:
751+ raise UndefinedOperationError(
752+ "Operation only defined for games with a tree representation"
753+ )
754+
746755 return GameNodes.wrap(self.game )
747756
748757 @property
@@ -1885,11 +1894,20 @@ class Game:
18851894
18861895 .. versionadded:: 16.4.0
18871896
1897+ Raises
1898+ ------
1899+ UndefinedOperationError
1900+ If the game does not have a tree representation.
1901+
18881902 See also
18891903 --------
18901904 Player.infosets
18911905 Infoset.members
18921906 """
1907+ if not self.is_tree:
1908+ raise UndefinedOperationError(
1909+ "Operation only defined for games with a tree representation"
1910+ )
18931911 self.game.deref().SortInfosets()
18941912
18951913 def add_player(self , label: str = " " ) -> Player:
Original file line number Diff line number Diff line change @@ -37,7 +37,14 @@ def test_strategic_game_root():
3737
3838def test_strategic_game_nodes ():
3939 game = gbt .Game .new_table ([2 , 2 ])
40- assert list (game .nodes ) == []
40+ with pytest .raises (gbt .UndefinedOperationError ):
41+ _ = game .nodes
42+
43+
44+ def test_strategic_game_sort_infosets ():
45+ game = gbt .Game .new_table ([2 , 2 ])
46+ with pytest .raises (gbt .UndefinedOperationError ):
47+ _ = game .sort_infosets ()
4148
4249
4350def test_game_behav_profile_error ():
You can’t perform that action at this time.
0 commit comments