Skip to content

Commit

Permalink
FIX: is_dominated: Return False if num_actions == 1
Browse files Browse the repository at this point in the history
  • Loading branch information
oyamad committed Nov 4, 2018
1 parent c3c6bd1 commit 281ce2c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions quantecon/game_theory/normal_form_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,8 @@ def is_dominated(self, action, tol=None, method=None):
ind[action] = False
D = payoff_array[ind]
D -= payoff_array[action]
if D.shape[0] == 0: # num_actions == 1
return False
if self.num_opponents >= 2:
D.shape = (D.shape[0], np.prod(D.shape[1:]))

Expand Down
18 changes: 18 additions & 0 deletions quantecon/game_theory/tests/test_normal_form_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,24 @@ def test_normalformgame_setitem_1p():
eq_(g.players[0].payoff_array[0], 10)


# Trivial cases with one action #

class TestPlayer_1action:
def setUp(self):
"""Setup a Player instance"""
self.payoffs = [[0, 1]]
self.player = Player(self.payoffs)

def test_is_dominated(self):
for action in range(self.player.num_actions):
for method in LP_METHODS:
eq_(self.player.is_dominated(action, method=method), False)

def test_dominated_actions(self):
for method in LP_METHODS:
eq_(self.player.dominated_actions(method=method), [])


# Test __repr__ #

def test_player_repr():
Expand Down

0 comments on commit 281ce2c

Please sign in to comment.