Skip to content

Commit c6d32c7

Browse files
committed
Add match_attributes to ProbEndRoundRobin
1 parent d565dea commit c6d32c7

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

axelrod/match_generator.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,9 @@ def build_single_match_params(self):
122122
"""
123123
Creates a single set of match parameters.
124124
"""
125-
return (self.sample_length(self.prob_end), self.game, None, self.noise)
125+
return (
126+
self.sample_length(self.prob_end), self.game, None, self.noise,
127+
{'length': float('inf'), 'game': self.game, 'noise': self.noise})
126128

127129
def sample_length(self, prob_end):
128130
"""

axelrod/tests/unit/test_match_generator.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ def test_len(self):
115115
self.assertEqual(len(rr), len(list(rr.build_match_chunks())))
116116
self.assertEqual(rr.estimated_size(), len(rr) * turns * repetitions)
117117

118+
118119
class TestProbEndRoundRobin(unittest.TestCase):
119120

120121
@classmethod
@@ -178,6 +179,7 @@ def test_build_single_match_params(self, prob_end, rm):
178179
self.assertIsInstance(match, axelrod.Match)
179180
self.assertLess(len(match), float('inf'))
180181
self.assertGreater(len(match), 0)
182+
self.assertEqual(match.players[0].match_attributes['length'], float('inf'))
181183

182184
# Testing with noise
183185
rr = axelrod.ProbEndRoundRobinMatches(
@@ -200,9 +202,8 @@ def test_build_single_match_params(self, prob_end, rm):
200202

201203
@given(prob_end=floats(min_value=.1, max_value=1), rm=random_module())
202204
def test_len(self, prob_end, rm):
203-
turns = 5
204205
repetitions = 10
205-
rr = axelrod.ProbEndRoundRobinMatches(self.players, prob_end, game=None,
206-
repetitions=repetitions)
206+
rr = axelrod.ProbEndRoundRobinMatches(
207+
self.players, prob_end, game=None, repetitions=repetitions)
207208
self.assertEqual(len(rr), len(list(rr.build_match_chunks())))
208209
self.assertAlmostEqual(rr.estimated_size(), len(rr) * 1. / prob_end * repetitions)

0 commit comments

Comments
 (0)