Skip to content

Commit 60d8672

Browse files
committed
Put keep_interactions back in as an option.
1 parent b094f30 commit 60d8672

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

axelrod/tests/unit/test_resultset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ def test_equality(self):
481481

482482
def test_interactions_equality(self):
483483
brs = axelrod.ResultSetFromFile(self.filename, progress_bar=False,
484-
keep_interactions=True)
484+
keep_interactions=True)
485485
rs = axelrod.ResultSet(self.players, self.interactions, progress_bar=False)
486486
self.assertEqual(rs.interactions, brs.interactions)
487487

axelrod/tournament.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def __init__(self, players, match_generator=RoundRobinMatches,
5656
self._logger = logging.getLogger(__name__)
5757

5858
def play(self, build_results=True, filename=None,
59-
processes=None, progress_bar=True):
59+
processes=None, progress_bar=True, keep_interactions=False):
6060
"""
6161
Plays the tournament and passes the results to the ResultSet class
6262
@@ -70,6 +70,9 @@ def play(self, build_results=True, filename=None,
7070
The number of processes to be used for parallel processing
7171
progress_bar : bool
7272
Whether or not to create a progress bar which will be updated
73+
keep_interactions : bool
74+
Whether or not to save the interactions to memory. Only relevant
75+
when writing to file.
7376
7477
Returns
7578
-------
@@ -106,24 +109,23 @@ def play(self, build_results=True, filename=None,
106109
self.outputfile.close()
107110

108111
if build_results:
109-
return self._build_result_set(progress_bar=progress_bar)
112+
return self._build_result_set(progress_bar=progress_bar,
113+
keep_interactions=keep_interactions)
110114

111-
def _build_result_set(self, progress_bar=True):
115+
def _build_result_set(self, progress_bar=True, keep_interactions=False):
112116
"""
113117
Build the result set (used by the play method)
114118
115119
Returns
116120
-------
117121
axelrod.BigResultSet
118122
"""
119-
# TODO Change ResultSet -> ResultSetFromDict and then have ResultSet
120-
# which recognises the inputs (if a filename is provided is brings in
121-
# ResultSetFromFile, if not it brings in ResultSetFromDict).
122123
if self.filename is not None:
123124
result_set = ResultSetFromFile(filename=self.filename,
124125
progress_bar=progress_bar,
125126
num_interactions=self.num_interactions,
126127
nrepetitions=self.repetitions,
128+
keep_interactions=keep_interactions,
127129
players=[str(p) for p in self.players],
128130
game=self.game)
129131
self.outputfile.close()

docs/tutorials/getting_started/tournament_results.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ We see that :code:`Cooperator` has no difference in score with all players
166166
except against the :code:`Defector`::
167167

168168
>>> results.score_diffs[0]
169-
[[-0.0, -0.0, -0.0], [-5.0, -5.0, -5.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]
169+
[[0.0, 0.0, 0.0], [-5.0, -5.0, -5.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]
170170

171171
Payoff difference means
172172
-----------------------

0 commit comments

Comments
 (0)