Skip to content
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: 4 additions & 0 deletions axelrod/result_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,8 @@ def summarise(self):
median_scores = map(np.nanmedian, self.normalised_scores)
median_wins = map(np.nanmedian, self.wins)

original_index = [index for index, _player in enumerate(self.players)]

self.player = namedtuple(
"Player",
[
Expand All @@ -718,6 +720,7 @@ def summarise(self):
"Cooperation_rating",
"Wins",
"Initial_C_rate",
"Original_index",
"CC_rate",
"CD_rate",
"DC_rate",
Expand Down Expand Up @@ -767,6 +770,7 @@ def summarise(self):
self.cooperating_rating,
median_wins,
self.initial_cooperation_rate,
original_index,
)
)

Expand Down
6 changes: 5 additions & 1 deletion axelrod/tests/unit/test_resultset.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,7 @@ def test_summarise_regression_test(self):
0.0,
3.0,
0.0,
1,
0.0,
0.0,
0.4000000000000001,
Expand All @@ -663,6 +664,7 @@ def test_summarise_regression_test(self):
0.7,
0.0,
1.0,
2,
0.6666666666666666,
0.03333333333333333,
0.0,
Expand All @@ -679,6 +681,7 @@ def test_summarise_regression_test(self):
0.7,
0.0,
1.0,
3,
0.6666666666666666,
0.03333333333333333,
0.0,
Expand All @@ -695,6 +698,7 @@ def test_summarise_regression_test(self):
1.0,
0.0,
1.0,
0,
0.6666666666666666,
0.3333333333333333,
0.0,
Expand Down Expand Up @@ -724,7 +728,7 @@ def test_write_summary(self):
csvreader = csv.reader(csvfile)
for row in csvreader:
ranked_names.append(row[1])
self.assertEqual(len(row), 14)
self.assertEqual(len(row), 15)
self.assertEqual(ranked_names[0], "Name")
self.assertEqual(ranked_names[1:], rs.ranked_names)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ that summarises the results of the tournament::
>>> summary = results.summarise()
>>> import pprint
>>> pprint.pprint(summary)
[Player(Rank=0, Name='Defector', Median_score=2.6..., Cooperation_rating=0.0, Wins=3.0, Initial_C_rate=0.0, CC_rate=...),
Player(Rank=1, Name='Tit For Tat', Median_score=2.3..., Cooperation_rating=0..., Wins=0.0, Initial_C_rate=1.0, CC_rate=...),
Player(Rank=2, Name='Grudger', Median_score=2.3..., Cooperation_rating=0..., Wins=0.0, Initial_C_rate=1.0, CC_rate=...),
Player(Rank=3, Name='Cooperator', Median_score=2.0..., Cooperation_rating=1.0, Wins=0.0, Initial_C_rate=1.0, CC_rate=...)]
[Player(Rank=0, Name='Defector', Median_score=2.6..., Cooperation_rating=0.0, Wins=3.0, Initial_C_rate=0.0, Original_index=1, CC_rate=...),
Player(Rank=1, Name='Tit For Tat', Median_score=2.3..., Cooperation_rating=0..., Wins=0.0, Initial_C_rate=1.0, Original_index=2, CC_rate=...),
Player(Rank=2, Name='Grudger', Median_score=2.3..., Cooperation_rating=0..., Wins=0.0, Initial_C_rate=1.0, Original_index=3, CC_rate=...),
Player(Rank=3, Name='Cooperator', Median_score=2.0..., Cooperation_rating=1.0, Wins=0.0, Initial_C_rate=1.0, Original_index=0, CC_rate=...)]

It is also possible to write this data directly to a csv file using the
`write_summary` method::
Expand All @@ -32,7 +32,7 @@ It is also possible to write this data directly to a csv file using the
... csvreader = csv.reader(outfile)
... for row in csvreader:
... print(row)
['Rank', 'Name', 'Median_score', 'Cooperation_rating', 'Wins', 'Initial_C_rate', 'CC_rate', 'CD_rate', 'DC_rate', 'DD_rate', 'CC_to_C_rate', 'CD_to_C_rate', 'DC_to_C_rate', 'DD_to_C_rate']
['Rank', 'Name', 'Median_score', 'Cooperation_rating', 'Wins', 'Initial_C_rate', 'Original_index', 'CC_rate', 'CD_rate', 'DC_rate', 'DD_rate', 'CC_to_C_rate', 'CD_to_C_rate', 'DC_to_C_rate', 'DD_to_C_rate']
['0', 'Defector', ...]
['1', 'Tit For Tat', ...]
['2', 'Grudger', ...]
Expand Down
Loading