Skip to content

Commit 8cccd1c

Browse files
committed
Merge pull request #559 from Axelrod-Python/552
Removing run_axelrod and factor/manager classes
2 parents cff633b + 053a6ea commit 8cccd1c

15 files changed

+41
-1116
lines changed

README.rst

+3-4
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,6 @@ Otherwise::
4747
$ cd Axelrod
4848
$ python setup.py install
4949

50-
You might need to install the libraries in `requirements.txt`::
51-
52-
pip install -r requirements.txt
53-
5450
Note that on Ubuntu `some
5551
users <https://github.com/Axelrod-Python/Axelrod/issues/309>`_ have had problems
5652
installing matplotlib. This seems to help with that::
@@ -80,6 +76,9 @@ gives::
8076

8177
['Meta Hunter', 'Inverse', 'Forgetful Fool Me Once', 'GTFT: 0.33', 'Champion', 'ZD-GTFT-2', 'Eatherley', 'Math Constant Hunter', 'Random Hunter', 'Soft Joss: 0.9', 'Meta Majority', 'Nice Average Copier', 'Feld', 'Meta Minority', 'Grofman', 'Stochastic WSLS', 'ZD-Extort-2', 'Tullock', 'Joss: 0.9', 'Arrogant QLearner', 'Average Copier', 'Cautious QLearner', 'Hesitant QLearner', 'Risky QLearner', 'Random: 0.5', 'Meta Winner']
8278

79+
There is also a `notebooks repository
80+
<https://github.com/Axelrod-Python/Axelrod-notebooks>`_ which shows further
81+
examples of using the library.
8382

8483
Results
8584
=======

axelrod/__init__.py

-4
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,5 @@
1313
from .deterministic_cache import DeterministicCache
1414
from .match_generator import *
1515
from .tournament import Tournament, ProbEndTournament
16-
from .tournament_manager import TournamentManager, ProbEndTournamentManager
17-
from .tournament_manager_factory import (TournamentManagerFactory,
18-
ProbEndTournamentManagerFactory)
1916
from .result_set import ResultSet, ResultSetFromFile
2017
from .ecosystem import Ecosystem
21-
from .utils import run_tournaments, run_prob_end_tournaments, setup_logging

axelrod/tests/integration/test_tournament.py

-93
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
import os
33
import axelrod
44

5-
from axelrod.utils import setup_logging, run_tournaments, run_prob_end_tournaments
6-
75

86
class TestTournament(unittest.TestCase):
97

@@ -57,94 +55,3 @@ def test_parallel_play(self):
5755
scores = tournament.play().scores
5856
actual_outcome = sorted(zip(self.player_names, scores))
5957
self.assertEqual(actual_outcome, self.expected_outcome)
60-
61-
62-
class TestTournamentManager(unittest.TestCase):
63-
64-
@classmethod
65-
def setUpClass(cls):
66-
cls.game = axelrod.Game()
67-
cls.players = [s() for s in axelrod.demo_strategies]
68-
69-
def test_tournament_manager(self):
70-
strategies = [s() for s in axelrod.demo_strategies]
71-
tm = axelrod.TournamentManager(
72-
"./", False, load_cache=False, save_cache=False)
73-
tm.add_tournament("test", strategies, repetitions=2, turns=10,
74-
noise=0.05)
75-
tm.run_tournaments()
76-
77-
strategies = [s() for s in axelrod.basic_strategies]
78-
tm = axelrod.TournamentManager("./", False, load_cache=False,
79-
save_cache=True)
80-
tm.add_tournament("test", strategies, repetitions=2, turns=10, noise=0.)
81-
tm.run_tournaments()
82-
83-
tm = axelrod.TournamentManager("./", False, load_cache=True,
84-
save_cache=True)
85-
tm.add_tournament("test", strategies, repetitions=2, turns=10, noise=0.)
86-
tm.run_tournaments()
87-
88-
def test_utils(self):
89-
setup_logging(logging_destination="none")
90-
run_tournaments(cache_file='',
91-
output_directory='./',
92-
repetitions=2,
93-
turns=10,
94-
processes=None,
95-
no_ecological=False,
96-
rebuild_cache=False,
97-
exclude_combined=True,
98-
exclude_basic=False,
99-
exclude_cheating=True,
100-
exclude_ordinary=True,
101-
noise=0)
102-
103-
104-
class TestProbEndTournamentManager(unittest.TestCase):
105-
106-
@classmethod
107-
def setUpClass(cls):
108-
cls.game = axelrod.Game()
109-
cls.players = [s() for s in axelrod.demo_strategies]
110-
111-
@classmethod
112-
def tearDownClass(cls):
113-
os.remove('./basic_strategies_prob_end.csv')
114-
os.remove('./test-prob-end.csv')
115-
116-
def test_tournament_manager(self):
117-
strategies = [s() for s in axelrod.demo_strategies]
118-
tm = axelrod.ProbEndTournamentManager(
119-
"./", False, load_cache=False, save_cache=False)
120-
tm.add_tournament("test-prob-end", strategies, repetitions=2, prob_end=.5,
121-
noise=0.05)
122-
tm.run_tournaments()
123-
124-
strategies = [s() for s in axelrod.basic_strategies]
125-
tm = axelrod.ProbEndTournamentManager("./", False, load_cache=False,
126-
save_cache=True)
127-
tm.add_tournament("test-prob-end", strategies, repetitions=2,
128-
prob_end=.5, noise=0.)
129-
tm.run_tournaments()
130-
131-
tm = axelrod.ProbEndTournamentManager("./", False, load_cache=True,
132-
save_cache=True)
133-
tm.add_tournament("test-prob-end", strategies, repetitions=2,
134-
prob_end=.5, noise=0.)
135-
tm.run_tournaments()
136-
137-
def test_utils(self):
138-
setup_logging(logging_destination="none")
139-
run_prob_end_tournaments(cache_file='',
140-
output_directory='./',
141-
repetitions=2,
142-
prob_end=.5,
143-
processes=None,
144-
no_ecological=False,
145-
rebuild_cache=False,
146-
exclude_combined=True,
147-
exclude_basic=False,
148-
exclude_cheating=True,
149-
exclude_ordinary=True,
150-
noise=0)

axelrod/tests/unit/test_plot.py

+14
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,13 @@ def test_winplot(self):
119119
else:
120120
self.skipTest('matplotlib not installed')
121121

122+
def test_sdvplot(self):
123+
if matplotlib_installed:
124+
plot = axelrod.Plot(self.test_result_set)
125+
self.assertIsInstance(plot.sdvplot(), matplotlib.pyplot.Figure)
126+
else:
127+
self.skipTest('matplotlib not installed')
128+
122129
def test_lengthplot_dataset(self):
123130
plot = axelrod.Plot(self.test_result_set)
124131
self.assertSequenceEqual(
@@ -132,6 +139,13 @@ def test_lengthplot(self):
132139
else:
133140
self.skipTest('matplotlib not installed')
134141

142+
def test_pdplot(self):
143+
if matplotlib_installed:
144+
plot = axelrod.Plot(self.test_result_set)
145+
self.assertIsInstance(plot.pdplot(), matplotlib.pyplot.Figure)
146+
else:
147+
self.skipTest('matplotlib not installed')
148+
135149
def test_payoff_dataset(self):
136150
plot = axelrod.Plot(self.test_result_set)
137151
self.assertSequenceEqual(

axelrod/tests/unit/test_tournament.py

+13-32
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ def test_init(self):
7171
self.assertEqual(tournament.repetitions, 10)
7272
self.assertEqual(tournament.name, 'test')
7373
self.assertEqual(tournament._processes, 4)
74-
self.assertFalse(tournament.prebuilt_cache)
7574
self.assertTrue(tournament._with_morality)
7675
self.assertIsInstance(tournament._logger, logging.Logger)
7776
self.assertEqual(tournament.deterministic_cache, {})
@@ -91,7 +90,6 @@ def test_init(self):
9190
noise=0.2,
9291
deterministic_cache=cache)
9392
self.assertEqual(tournament.deterministic_cache, cache)
94-
self.assertTrue(tournament.prebuilt_cache)
9593

9694
def test_serial_play(self):
9795
# Test that we get an instance of ResultSet
@@ -180,61 +178,46 @@ def test_parallel_play(self):
180178
self.assertEqual(len(scores), len(players))
181179

182180
def test_build_cache_required(self):
183-
# Noisy, no prebuilt cache, empty deterministic cache
181+
# Noisy empty deterministic cache
182+
cache = axelrod.DeterministicCache()
184183
tournament = axelrod.Tournament(
185184
name=self.test_name,
186185
players=self.players,
187186
game=self.game,
188187
processes=4,
189188
noise=0.2,
190-
prebuilt_cache=False)
189+
deterministic_cache=cache)
191190
self.assertFalse(tournament._build_cache_required())
192191

193-
# Noisy, with prebuilt cache, empty deterministic cache
192+
# Not noisy, deterministic cache has content
193+
key = (axelrod.TitForTat, axelrod.Defector, 3)
194+
cache[key] = [('C', 'D'), ('D', 'D'), ('D', 'D')]
194195
tournament = axelrod.Tournament(
195196
name=self.test_name,
196197
players=self.players,
198+
game=self.game,
197199
processes=4,
198200
noise=0.2,
199-
prebuilt_cache=True)
201+
deterministic_cache=cache)
200202
self.assertFalse(tournament._build_cache_required())
201203

202-
# Not noisy, with prebuilt cache, deterministic cache has content
204+
# Not noisy, deterministic cache has content
203205
tournament = axelrod.Tournament(
204206
name=self.test_name,
205207
players=self.players,
206208
game=self.game,
207209
processes=4,
208-
prebuilt_cache=True)
209-
tournament.deterministic_cache = {'test': 100}
210+
deterministic_cache=cache)
210211
self.assertFalse(tournament._build_cache_required())
211212

212-
# Not noisy, no prebuilt cache, deterministic cache has content
213-
tournament = axelrod.Tournament(
214-
name=self.test_name,
215-
players=self.players,
216-
game=self.game,
217-
processes=4,
218-
prebuilt_cache=False)
219-
tournament.deterministic_cache = {'test': 100}
220-
self.assertTrue(tournament._build_cache_required())
221-
222-
# Not noisy, with prebuilt cache, empty deterministic cache
223-
tournament = axelrod.Tournament(
224-
name=self.test_name,
225-
players=self.players,
226-
game=self.game,
227-
processes=4,
228-
prebuilt_cache=True)
229-
self.assertTrue(tournament._build_cache_required())
230-
231-
# Not noisy, no prebuilt cache, empty deterministic cache
213+
# Not noisy, empty deterministic cache
214+
cache = axelrod.DeterministicCache()
232215
tournament = axelrod.Tournament(
233216
name=self.test_name,
234217
players=self.players,
235218
game=self.game,
236219
processes=4,
237-
prebuilt_cache=False)
220+
deterministic_cache=cache)
238221
self.assertTrue(tournament._build_cache_required())
239222

240223
def test_build_cache(self):
@@ -559,7 +542,6 @@ def test_init(self):
559542
self.assertEqual(tournament.repetitions, 10)
560543
self.assertEqual(tournament.name, 'test')
561544
self.assertEqual(tournament._processes, None)
562-
self.assertFalse(tournament.prebuilt_cache)
563545
self.assertTrue(tournament._with_morality)
564546
self.assertIsInstance(tournament._logger, logging.Logger)
565547
self.assertEqual(tournament.deterministic_cache, {})
@@ -579,7 +561,6 @@ def test_init(self):
579561
noise=0.2,
580562
deterministic_cache=cache)
581563
self.assertEqual(tournament.deterministic_cache, cache)
582-
self.assertTrue(tournament.prebuilt_cache)
583564

584565
@given(s=lists(sampled_from(axelrod.strategies),
585566
min_size=2, # Errors are returned if less than 2 strategies

axelrod/tests/unit/test_tournament_manager.py

-106
This file was deleted.

0 commit comments

Comments
 (0)