Skip to content

Commit

Permalink
Merge pull request #559 from Axelrod-Python/552
Browse files Browse the repository at this point in the history
Removing run_axelrod and factor/manager classes
  • Loading branch information
meatballs committed Apr 25, 2016
2 parents cff633b + 053a6ea commit 8cccd1c
Show file tree
Hide file tree
Showing 15 changed files with 41 additions and 1,116 deletions.
7 changes: 3 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ Otherwise::
$ cd Axelrod
$ python setup.py install

You might need to install the libraries in `requirements.txt`::

pip install -r requirements.txt

Note that on Ubuntu `some
users <https://github.com/Axelrod-Python/Axelrod/issues/309>`_ have had problems
installing matplotlib. This seems to help with that::
Expand Down Expand Up @@ -80,6 +76,9 @@ gives::

['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']

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

Results
=======
Expand Down
4 changes: 0 additions & 4 deletions axelrod/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,5 @@
from .deterministic_cache import DeterministicCache
from .match_generator import *
from .tournament import Tournament, ProbEndTournament
from .tournament_manager import TournamentManager, ProbEndTournamentManager
from .tournament_manager_factory import (TournamentManagerFactory,
ProbEndTournamentManagerFactory)
from .result_set import ResultSet, ResultSetFromFile
from .ecosystem import Ecosystem
from .utils import run_tournaments, run_prob_end_tournaments, setup_logging
93 changes: 0 additions & 93 deletions axelrod/tests/integration/test_tournament.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
import os
import axelrod

from axelrod.utils import setup_logging, run_tournaments, run_prob_end_tournaments


class TestTournament(unittest.TestCase):

Expand Down Expand Up @@ -57,94 +55,3 @@ def test_parallel_play(self):
scores = tournament.play().scores
actual_outcome = sorted(zip(self.player_names, scores))
self.assertEqual(actual_outcome, self.expected_outcome)


class TestTournamentManager(unittest.TestCase):

@classmethod
def setUpClass(cls):
cls.game = axelrod.Game()
cls.players = [s() for s in axelrod.demo_strategies]

def test_tournament_manager(self):
strategies = [s() for s in axelrod.demo_strategies]
tm = axelrod.TournamentManager(
"./", False, load_cache=False, save_cache=False)
tm.add_tournament("test", strategies, repetitions=2, turns=10,
noise=0.05)
tm.run_tournaments()

strategies = [s() for s in axelrod.basic_strategies]
tm = axelrod.TournamentManager("./", False, load_cache=False,
save_cache=True)
tm.add_tournament("test", strategies, repetitions=2, turns=10, noise=0.)
tm.run_tournaments()

tm = axelrod.TournamentManager("./", False, load_cache=True,
save_cache=True)
tm.add_tournament("test", strategies, repetitions=2, turns=10, noise=0.)
tm.run_tournaments()

def test_utils(self):
setup_logging(logging_destination="none")
run_tournaments(cache_file='',
output_directory='./',
repetitions=2,
turns=10,
processes=None,
no_ecological=False,
rebuild_cache=False,
exclude_combined=True,
exclude_basic=False,
exclude_cheating=True,
exclude_ordinary=True,
noise=0)


class TestProbEndTournamentManager(unittest.TestCase):

@classmethod
def setUpClass(cls):
cls.game = axelrod.Game()
cls.players = [s() for s in axelrod.demo_strategies]

@classmethod
def tearDownClass(cls):
os.remove('./basic_strategies_prob_end.csv')
os.remove('./test-prob-end.csv')

def test_tournament_manager(self):
strategies = [s() for s in axelrod.demo_strategies]
tm = axelrod.ProbEndTournamentManager(
"./", False, load_cache=False, save_cache=False)
tm.add_tournament("test-prob-end", strategies, repetitions=2, prob_end=.5,
noise=0.05)
tm.run_tournaments()

strategies = [s() for s in axelrod.basic_strategies]
tm = axelrod.ProbEndTournamentManager("./", False, load_cache=False,
save_cache=True)
tm.add_tournament("test-prob-end", strategies, repetitions=2,
prob_end=.5, noise=0.)
tm.run_tournaments()

tm = axelrod.ProbEndTournamentManager("./", False, load_cache=True,
save_cache=True)
tm.add_tournament("test-prob-end", strategies, repetitions=2,
prob_end=.5, noise=0.)
tm.run_tournaments()

def test_utils(self):
setup_logging(logging_destination="none")
run_prob_end_tournaments(cache_file='',
output_directory='./',
repetitions=2,
prob_end=.5,
processes=None,
no_ecological=False,
rebuild_cache=False,
exclude_combined=True,
exclude_basic=False,
exclude_cheating=True,
exclude_ordinary=True,
noise=0)
14 changes: 14 additions & 0 deletions axelrod/tests/unit/test_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ def test_winplot(self):
else:
self.skipTest('matplotlib not installed')

def test_sdvplot(self):
if matplotlib_installed:
plot = axelrod.Plot(self.test_result_set)
self.assertIsInstance(plot.sdvplot(), matplotlib.pyplot.Figure)
else:
self.skipTest('matplotlib not installed')

def test_lengthplot_dataset(self):
plot = axelrod.Plot(self.test_result_set)
self.assertSequenceEqual(
Expand All @@ -132,6 +139,13 @@ def test_lengthplot(self):
else:
self.skipTest('matplotlib not installed')

def test_pdplot(self):
if matplotlib_installed:
plot = axelrod.Plot(self.test_result_set)
self.assertIsInstance(plot.pdplot(), matplotlib.pyplot.Figure)
else:
self.skipTest('matplotlib not installed')

def test_payoff_dataset(self):
plot = axelrod.Plot(self.test_result_set)
self.assertSequenceEqual(
Expand Down
45 changes: 13 additions & 32 deletions axelrod/tests/unit/test_tournament.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ def test_init(self):
self.assertEqual(tournament.repetitions, 10)
self.assertEqual(tournament.name, 'test')
self.assertEqual(tournament._processes, 4)
self.assertFalse(tournament.prebuilt_cache)
self.assertTrue(tournament._with_morality)
self.assertIsInstance(tournament._logger, logging.Logger)
self.assertEqual(tournament.deterministic_cache, {})
Expand All @@ -91,7 +90,6 @@ def test_init(self):
noise=0.2,
deterministic_cache=cache)
self.assertEqual(tournament.deterministic_cache, cache)
self.assertTrue(tournament.prebuilt_cache)

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

def test_build_cache_required(self):
# Noisy, no prebuilt cache, empty deterministic cache
# Noisy empty deterministic cache
cache = axelrod.DeterministicCache()
tournament = axelrod.Tournament(
name=self.test_name,
players=self.players,
game=self.game,
processes=4,
noise=0.2,
prebuilt_cache=False)
deterministic_cache=cache)
self.assertFalse(tournament._build_cache_required())

# Noisy, with prebuilt cache, empty deterministic cache
# Not noisy, deterministic cache has content
key = (axelrod.TitForTat, axelrod.Defector, 3)
cache[key] = [('C', 'D'), ('D', 'D'), ('D', 'D')]
tournament = axelrod.Tournament(
name=self.test_name,
players=self.players,
game=self.game,
processes=4,
noise=0.2,
prebuilt_cache=True)
deterministic_cache=cache)
self.assertFalse(tournament._build_cache_required())

# Not noisy, with prebuilt cache, deterministic cache has content
# Not noisy, deterministic cache has content
tournament = axelrod.Tournament(
name=self.test_name,
players=self.players,
game=self.game,
processes=4,
prebuilt_cache=True)
tournament.deterministic_cache = {'test': 100}
deterministic_cache=cache)
self.assertFalse(tournament._build_cache_required())

# Not noisy, no prebuilt cache, deterministic cache has content
tournament = axelrod.Tournament(
name=self.test_name,
players=self.players,
game=self.game,
processes=4,
prebuilt_cache=False)
tournament.deterministic_cache = {'test': 100}
self.assertTrue(tournament._build_cache_required())

# Not noisy, with prebuilt cache, empty deterministic cache
tournament = axelrod.Tournament(
name=self.test_name,
players=self.players,
game=self.game,
processes=4,
prebuilt_cache=True)
self.assertTrue(tournament._build_cache_required())

# Not noisy, no prebuilt cache, empty deterministic cache
# Not noisy, empty deterministic cache
cache = axelrod.DeterministicCache()
tournament = axelrod.Tournament(
name=self.test_name,
players=self.players,
game=self.game,
processes=4,
prebuilt_cache=False)
deterministic_cache=cache)
self.assertTrue(tournament._build_cache_required())

def test_build_cache(self):
Expand Down Expand Up @@ -559,7 +542,6 @@ def test_init(self):
self.assertEqual(tournament.repetitions, 10)
self.assertEqual(tournament.name, 'test')
self.assertEqual(tournament._processes, None)
self.assertFalse(tournament.prebuilt_cache)
self.assertTrue(tournament._with_morality)
self.assertIsInstance(tournament._logger, logging.Logger)
self.assertEqual(tournament.deterministic_cache, {})
Expand All @@ -579,7 +561,6 @@ def test_init(self):
noise=0.2,
deterministic_cache=cache)
self.assertEqual(tournament.deterministic_cache, cache)
self.assertTrue(tournament.prebuilt_cache)

@given(s=lists(sampled_from(axelrod.strategies),
min_size=2, # Errors are returned if less than 2 strategies
Expand Down
106 changes: 0 additions & 106 deletions axelrod/tests/unit/test_tournament_manager.py

This file was deleted.

Loading

0 comments on commit 8cccd1c

Please sign in to comment.