Skip to content

Commit 423b59f

Browse files
committed
Cleanup post rebase, update some imports
1 parent bad199e commit 423b59f

30 files changed

+68
-101
lines changed

axelrod/evolvable_player.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import base64
2-
import copy
32
from pickle import dumps, loads
43
from typing import Dict, List
54
from .player import Player

axelrod/match.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from axelrod import Classifiers
77
from axelrod.game import Game
88
from axelrod.random_ import RandomGenerator
9-
from .deterministic_cache import DeterministicCache
9+
from axelrod.deterministic_cache import DeterministicCache
1010

1111
C, D = Action.C, Action.D
1212

axelrod/moran.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
import numpy as np
88
from axelrod import EvolvablePlayer, DEFAULT_TURNS, Game, Player
99

10-
from .deterministic_cache import DeterministicCache
11-
from .graph import Graph, complete_graph
12-
from .match import Match
13-
from .random_ import RandomGenerator, BulkRandomGenerator
10+
from axelrod.deterministic_cache import DeterministicCache
11+
from axelrod.graph import Graph, complete_graph
12+
from axelrod.match import Match
13+
from axelrod.random_ import RandomGenerator, BulkRandomGenerator
1414

1515

1616
class MoranProcess(object):

axelrod/plot.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
from distutils.version import LooseVersion
2+
import pathlib
23
from typing import List, Union
34

45
import matplotlib
56
import matplotlib.pyplot as plt
67
import matplotlib.transforms as transforms
7-
import pathlib
8-
import tqdm
98
from numpy import arange, median, nan_to_num
9+
import tqdm
1010

1111
from .result_set import ResultSet
1212
from .load_data_ import axl_filename

axelrod/result_set.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55
from typing import List
66
import warnings
77

8-
import numpy as np
9-
import tqdm
10-
118
import dask as da
129
import dask.dataframe as dd
10+
import numpy as np
11+
import tqdm
1312

1413
from axelrod.action import Action
1514
from . import eigen

axelrod/tests/integration/test_filtering.py

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import warnings
33

44
import axelrod as axl
5-
from axelrod import filtered_strategies, short_run_time_strategies
65
from axelrod.tests.property import strategy_lists
76

87
from hypothesis import example, given, settings

axelrod/tests/strategies/test_axelrod_second.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
"""Tests for the Second Axelrod strategies."""
22

3-
import random
4-
53
import axelrod as axl
6-
7-
import numpy as np
8-
94
from .test_player import TestPlayer
105

116
C, D = axl.Action.C, axl.Action.D
@@ -1155,9 +1150,8 @@ def test_strategy(self):
11551150
]
11561151
# Enter defect mode.
11571152
expected_actions += [(D, C)]
1158-
random.seed(10)
11591153
player = self.player()
1160-
match = axl.Match((player, axl.Random()), turns=len(expected_actions))
1154+
match = axl.Match((player, axl.Random()), turns=len(expected_actions), seed=10)
11611155
# The history matrix will be [[0, 2], [5, 6], [3, 6], [4, 2]]
11621156
actions = match.play()
11631157
self.assertEqual(actions, expected_actions)

axelrod/tests/strategies/test_cycler.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""Tests for the Cycler strategies."""
22
import unittest
33
import itertools
4-
import random
54

65
import axelrod as axl
76
from axelrod._strategy_utils import detect_cycle
@@ -12,6 +11,7 @@
1211
from .test_evolvable_player import PartialClass, TestEvolvablePlayer
1312

1413
C, D = Action.C, Action.D
14+
random = axl.RandomGenerator()
1515

1616

1717
class TestAntiCycler(TestPlayer):

axelrod/tests/strategies/test_evolvable_player.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import unittest
21
import functools
32
import unittest
43

axelrod/tests/strategies/test_finite_state_machines.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
"""Tests for Finite State Machine Strategies."""
2-
32
import unittest
43

5-
import random
6-
74
import axelrod as axl
85
from axelrod.compute_finite_state_machine_memory import get_memory_from_transitions
96
from axelrod.evolvable_player import InsufficientParametersError
@@ -13,7 +10,7 @@
1310
from .test_evolvable_player import PartialClass, TestEvolvablePlayer
1411

1512
C, D = axl.Action.C, axl.Action.D
16-
13+
random = axl.RandomGenerator()
1714

1815
class TestSimpleFSM(unittest.TestCase):
1916
def setUp(self):

axelrod/tests/strategies/test_gambler.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
"""Test for the Gambler strategy. Most tests come from the LookerUp test suite.
22
"""
3-
import unittest
4-
53
import copy
6-
7-
import random
4+
import unittest
85

96
import axelrod as axl
107
from axelrod.load_data_ import load_pso_tables
@@ -17,7 +14,7 @@
1714

1815
tables = load_pso_tables("pso_gambler.csv", directory="data")
1916
C, D = axl.Action.C, axl.Action.D
20-
17+
random = axl.RandomGenerator()
2118

2219
class TestGambler(TestPlayer):
2320

axelrod/tests/strategies/test_lookerup.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
"""Test for the Looker Up strategy."""
22

3-
import unittest
4-
53
import copy
6-
7-
import random
4+
import unittest
85

96
import axelrod as axl
107
from axelrod.action import str_to_actions
@@ -20,7 +17,7 @@
2017
from .test_player import TestPlayer
2118

2219
C, D = axl.Action.C, axl.Action.D
23-
20+
random = axl.RandomGenerator()
2421

2522
class TestLookupTable(unittest.TestCase):
2623
lookup_dict = {

axelrod/tests/strategies/test_mindreader.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Tests for the Mindreader strategy."""
22

3-
import axl as axl
3+
import axelrod as axl
44
from axelrod._strategy_utils import simulate_match
55

66
from .test_player import TestPlayer

axelrod/tests/strategies/test_qlearner.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
"""Tests for the QLearner strategies."""
22

3-
import random
4-
53
import axelrod as axl
6-
74
from .test_player import TestPlayer
85

96
C, D = axl.Action.C, axl.Action.D

axelrod/tests/strategies/test_retaliate.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import axelrod as axl
44

5-
from .test_player import TestOpponent, TestPlayer
5+
from .test_player import TestPlayer
66

77
C, D = axl.Action.C, axl.Action.D
88

axelrod/tests/strategies/test_selfsteem.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
"""Tests for the SelfSteem strategy."""
22

3-
import random
4-
53
import axelrod as axl
64

75
from .test_player import TestPlayer

axelrod/tests/unit/test_deterministic_cache.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import unittest
21
import os
32
import pathlib
43
import pickle
4+
import unittest
55

66
import axelrod as axl
77
from axelrod.load_data_ import axl_filename

axelrod/tests/unit/test_eigen.py

+16-17
Original file line numberDiff line numberDiff line change
@@ -2,51 +2,50 @@
22

33
import unittest
44

5-
import numpy
5+
import numpy as np
66
from numpy.testing import assert_array_almost_equal
77

88
from axelrod.eigen import _normalise, principal_eigenvector
99

1010

11-
1211
class FunctionCases(unittest.TestCase):
1312
def test_identity_matrices(self):
1413
for size in range(2, 6):
15-
mat = numpy.identity(size)
14+
mat = np.identity(size)
1615
evector, evalue = principal_eigenvector(mat)
1716
self.assertAlmostEqual(evalue, 1)
18-
assert_array_almost_equal(evector, _normalise(numpy.ones(size)))
17+
assert_array_almost_equal(evector, _normalise(np.ones(size)))
1918

2019
def test_zero_matrix(self):
21-
mat = numpy.array([[0, 0], [0, 0]])
20+
mat = np.array([[0, 0], [0, 0]])
2221
evector, evalue = principal_eigenvector(mat)
23-
self.assertTrue(numpy.isnan(evalue))
24-
self.assertTrue(numpy.isnan(evector[0]))
25-
self.assertTrue(numpy.isnan(evector[1]))
22+
self.assertTrue(np.isnan(evalue))
23+
self.assertTrue(np.isnan(evector[0]))
24+
self.assertTrue(np.isnan(evector[1]))
2625

2726
def test_2x2_matrix(self):
28-
mat = numpy.array([[2, 1], [1, 2]])
27+
mat = np.array([[2, 1], [1, 2]])
2928
evector, evalue = principal_eigenvector(mat)
3029
self.assertAlmostEqual(evalue, 3)
31-
assert_array_almost_equal(evector, numpy.dot(mat, evector) / evalue)
32-
assert_array_almost_equal(evector, _normalise(numpy.array([1, 1])))
30+
assert_array_almost_equal(evector, np.dot(mat, evector) / evalue)
31+
assert_array_almost_equal(evector, _normalise(np.array([1, 1])))
3332

3433
def test_3x3_matrix(self):
35-
mat = numpy.array([[1, 2, 0], [-2, 1, 2], [1, 3, 1]])
34+
mat = np.array([[1, 2, 0], [-2, 1, 2], [1, 3, 1]])
3635
evector, evalue = principal_eigenvector(
3736
mat, maximum_iterations=None, max_error=1e-10
3837
)
3938
self.assertAlmostEqual(evalue, 3)
40-
assert_array_almost_equal(evector, numpy.dot(mat, evector) / evalue)
41-
assert_array_almost_equal(evector, _normalise(numpy.array([0.5, 0.5, 1])))
39+
assert_array_almost_equal(evector, np.dot(mat, evector) / evalue)
40+
assert_array_almost_equal(evector, _normalise(np.array([0.5, 0.5, 1])))
4241

4342
def test_4x4_matrix(self):
44-
mat = numpy.array([[2, 0, 0, 0], [1, 2, 0, 0], [0, 1, 3, 0], [0, 0, 1, 3]])
43+
mat = np.array([[2, 0, 0, 0], [1, 2, 0, 0], [0, 1, 3, 0], [0, 0, 1, 3]])
4544
evector, evalue = principal_eigenvector(
4645
mat, maximum_iterations=None, max_error=1e-10
4746
)
4847
self.assertAlmostEqual(evalue, 3, places=3)
49-
assert_array_almost_equal(evector, numpy.dot(mat, evector) / evalue)
48+
assert_array_almost_equal(evector, np.dot(mat, evector) / evalue)
5049
assert_array_almost_equal(
51-
evector, _normalise(numpy.array([0, 0, 0, 1])), decimal=4
50+
evector, _normalise(np.array([0, 0, 0, 1])), decimal=4
5251
)

axelrod/tests/unit/test_fingerprint.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1+
import matplotlib.pyplot
2+
import os
3+
import pathlib
4+
from tempfile import mkstemp
15
import unittest
26
from unittest.mock import patch
37

4-
import os
5-
from tempfile import mkstemp
6-
import matplotlib.pyplot
8+
from hypothesis import given, settings
79
import numpy as np
8-
import pathlib
910

1011
import axelrod as axl
1112
from axelrod.fingerprint import AshlockFingerprint, Point, TransitiveFingerprint
1213
from axelrod.load_data_ import axl_filename
1314
from axelrod.tests.property import strategy_lists
1415

15-
from hypothesis import given, settings
16-
1716

1817
C, D = axl.Action.C, axl.Action.D
1918

axelrod/tests/unit/test_graph.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import unittest
2-
31
from collections import defaultdict
2+
import unittest
43

54
import axelrod as axl
65

axelrod/tests/unit/test_history.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import unittest
2-
31
from collections import Counter
2+
import unittest
43

54
import axelrod as axl
65
from axelrod.history import History, LimitedHistory

axelrod/tests/unit/test_interaction_utils.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import unittest
2-
import tempfile
31
from collections import Counter
2+
import tempfile
3+
import unittest
44

55
import axelrod as axl
66

axelrod/tests/unit/test_match.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
import unittest
2-
31
from collections import Counter
2+
import unittest
43

5-
import axelrod as axl
64
from hypothesis import example, given
75
from hypothesis.strategies import floats, integers
86

9-
from axelrod import Action
7+
import axelrod as axl
108
from axelrod.deterministic_cache import DeterministicCache
119
from axelrod.random_ import RandomGenerator
1210
from axelrod.tests.property import games

axelrod/tests/unit/test_moran.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import unittest
2-
import itertools
3-
import random
41
from collections import Counter
2+
import itertools
3+
import unittest
4+
55
import matplotlib.pyplot as plt
6+
67
import axelrod as axl
78
from axelrod import MoranProcess
89
from axelrod.tests.property import strategy_lists
@@ -12,6 +13,7 @@
1213

1314

1415
C, D = axl.Action.C, axl.Action.D
16+
random = axl.RandomGenerator()
1517

1618

1719
class TestMoranProcess(unittest.TestCase):

axelrod/tests/unit/test_pickling.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import unittest
21
import pickle
3-
import random
2+
import unittest
43

54
import axelrod as axl
65

76
C, D = axl.Action.C, axl.Action.D
8-
7+
random = axl.RandomGenerator()
98

109
# A set of classes to test pickling.
1110

axelrod/tests/unit/test_plot.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1+
import pathlib
2+
import tempfile
13
import unittest
24

3-
import tempfile
45
import matplotlib
56
import matplotlib.pyplot as plt
6-
import pathlib
7-
87
from numpy import mean
98

109
import axelrod as axl

0 commit comments

Comments
 (0)