Skip to content

Correction to deterministic cache test #882

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions axelrod/mock_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ def __init__(self, actions: List[Action] =None, history: List[Action] =None, sta
if actions:
self.actions = cycle(actions)
else:
self.actions = []
self.actions = iter([])

def strategy(self, opponent: Player) -> Action:
# Return the next saved action, if present.
try:
action = self.actions.__next__()
return action
except AttributeError:
except StopIteration:
return C


Expand Down
4 changes: 2 additions & 2 deletions axelrod/strategies/apavlov.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class APavlov2006(Player):

def __init__(self) -> None:
super().__init__()
self.opponent_class = None
self.opponent_class = None # type: str

def strategy(self, opponent: Player) -> Action:
# TFT for six rounds
Expand Down Expand Up @@ -96,7 +96,7 @@ class APavlov2011(Player):

def __init__(self) -> None:
super().__init__()
self.opponent_class = None
self.opponent_class = None # type: str

def strategy(self, opponent: Player) -> Action:
# TFT for six rounds
Expand Down
11 changes: 6 additions & 5 deletions axelrod/tests/unit/test_deterministic_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,13 @@ def test_is_valid_key(self):
# Should return false if contents of tuple are not axelrod Players
# and an integer
self.assertFalse(cache._is_valid_key(('test', 'test', 'test')))
self.assertFalse(cache._is_valid_key((TitForTat, 'test', 2)))
self.assertFalse(cache._is_valid_key(('test', TitForTat, 2)))
self.assertFalse(cache._is_valid_key((TitForTat, TitForTat, TitForTat)))
self.assertFalse(cache._is_valid_key((TitForTat(), 'test', 2)))
self.assertFalse(cache._is_valid_key(('test', TitForTat(), 2)))
self.assertFalse(cache._is_valid_key(
(TitForTat(), TitForTat(), TitForTat())))
# Should return false if either player class is stochastic
self.assertFalse(cache._is_valid_key((Random, TitForTat, 2)))
self.assertFalse(cache._is_valid_key((TitForTat, Random, 2)))
self.assertFalse(cache._is_valid_key((Random(), TitForTat(), 2)))
self.assertFalse(cache._is_valid_key((TitForTat(), Random(), 2)))

def test_is_valid_value(self):
cache = DeterministicCache()
Expand Down