Skip to content

Commit 792f402

Browse files
authored
Merge pull request #682 from marcharper/style
Style and Temp file closing warning fix
2 parents 33a595d + eebde3e commit 792f402

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+194
-260
lines changed

axelrod/_strategy_utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,7 @@ def __repr__(self):
112112
@Memoized
113113
def recursive_thue_morse(n):
114114
"""The recursive definition of the Thue-Morse sequence. The first few terms
115-
of the Thue-Morse sequence are:
116-
0 1 1 0 1 0 0 1 1 0 0 1 0 1 1 0 . . ."""
115+
of the Thue-Morse sequence are: 0 1 1 0 1 0 0 1 1 0 0 1 0 1 1 0 . . ."""
117116

118117
if n == 0:
119118
return 0

axelrod/ecosystem.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import random
32

43

axelrod/match_generator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,10 @@ def build_single_match_params(self):
123123
Creates a single set of match parameters.
124124
"""
125125
return (
126-
self.sample_length(self.prob_end), self.game, None, self.noise,
126+
self.sample_length(), self.game, None, self.noise,
127127
{'length': float('inf'), 'game': self.game, 'noise': self.noise})
128128

129-
def sample_length(self, prob_end):
129+
def sample_length(self):
130130
"""
131131
Sample length of a game.
132132

axelrod/player.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,9 @@ def clone(self):
149149

150150
def reset(self):
151151
"""Resets history.
152-
153-
When creating strategies that create new attributes then this method should be
154-
re-written (in the inherited class) and should not only reset history but also
155-
rest all other attributes.
152+
When creating strategies that create new attributes then this method
153+
should be re-written (in the inherited class) and should not only reset
154+
history but also rest all other attributes.
156155
"""
157156
self.history = []
158157
self.cooperations = 0

axelrod/plot.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,6 @@ def winplot(self, title=None):
103103
def _sd_ordering(self):
104104
return self.result_set.ranking
105105

106-
# Sort by median then max
107-
# from operator import itemgetter
108-
# diffs = self.result_set.score_diffs
109-
# to_sort = [(median(d), max(d), i) for (i, d) in enumerate(diffs)]
110-
# to_sort.sort(reverse=True, key=itemgetter(0, 1))
111-
# ordering = [x[-1] for x in to_sort]
112-
# return ordering
113-
114106
@property
115107
def _sdv_plot_dataset(self):
116108
ordering = self._sd_ordering
@@ -231,7 +223,8 @@ def stackplot(self, eco, title=None, logscale=True):
231223
for i, n in enumerate(self.result_set.ranked_names):
232224
x = -0.01
233225
y = (i + 0.5) * 1.0 / self.result_set.nplayers
234-
ax.annotate(n, xy=(x, y), xycoords=trans, clip_on=False, va='center', ha='right', fontsize=5)
226+
ax.annotate(n, xy=(x, y), xycoords=trans, clip_on=False,
227+
va='center', ha='right', fontsize=5)
235228
ticks.append(y)
236229
ax.set_yticks(ticks)
237230
ax.tick_params(direction='out')

axelrod/result_set.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from collections import defaultdict
21
import csv
32
import tqdm
43

@@ -8,13 +7,6 @@
87
from .game import Game
98
import axelrod.interaction_utils as iu
109

11-
try:
12-
# Python 2
13-
from StringIO import StringIO
14-
except ImportError:
15-
# Python 3
16-
from io import StringIO
17-
1810

1911
def update_progress_bar(method):
2012
"""A decorator to update a progress bar if it exists"""

axelrod/strategies/adaptive.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from axelrod import Actions, Player, Game, init_args
1+
from axelrod import Actions, Player, init_args
22

33
C, D = Actions.C, Actions.D
44

axelrod/strategies/apavlov.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from axelrod import Actions, Player, flip_action
1+
from axelrod import Actions, Player
22

33
C, D = Actions.C, Actions.D
44

@@ -51,15 +51,15 @@ def strategy(self, opponent):
5151
if self.opponent_class == "STFT":
5252
if len(self.history) % 6 in [0, 1]:
5353
return C
54-
#TFT
54+
# TFT
5555
if opponent.history[-1:] == [D]:
5656
return D
5757
if self.opponent_class == "PavlovD":
5858
# Return D then C for the period
5959
if len(self.history) % 6 == 0:
6060
return D
6161
if self.opponent_class == "Cooperative":
62-
#TFT
62+
# TFT
6363
if opponent.history[-1:] == [D]:
6464
return D
6565
return C
@@ -112,10 +112,10 @@ def strategy(self, opponent):
112112
if self.opponent_class in ["Random", "ALLD"]:
113113
return D
114114
if self.opponent_class == "STFT":
115-
#TFTT
115+
# TFTT
116116
return D if opponent.history[-2:] == [D, D] else C
117117
if self.opponent_class == "Cooperative":
118-
#TFT
118+
# TFT
119119
return D if opponent.history[-1:] == [D] else C
120120

121121
def reset(self):

axelrod/strategies/averagecopier.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import random
2-
31
from axelrod import Actions, Player, random_choice
42

53

axelrod/strategies/axelrod_first.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
Additional strategies from Axelrod's first tournament.
33
"""
44

5-
from math import sqrt
65
import random
76

8-
from axelrod import Actions, Game, Player, init_args, flip_action, random_choice
7+
from axelrod import Actions, Player, init_args, flip_action, random_choice
98

109
from.memoryone import MemoryOnePlayer
1110

0 commit comments

Comments
 (0)