diff --git a/axelrod/ecosystem.py b/axelrod/ecosystem.py index 4c3bfb907..aa2ad9a93 100644 --- a/axelrod/ecosystem.py +++ b/axelrod/ecosystem.py @@ -33,7 +33,7 @@ def __init__( population: List[int] = None, ) -> None: """Create a new ecosystem. - + Parameters ---------- results: ResultSet @@ -83,7 +83,7 @@ def __init__( def reproduce(self, turns: int): """Reproduce populations according to the payoff matrix. - + Parameters ---------- turns: int diff --git a/axelrod/game.py b/axelrod/game.py index af30aca29..180a9f110 100644 --- a/axelrod/game.py +++ b/axelrod/game.py @@ -20,7 +20,7 @@ def __init__( self, r: Score = 3, s: Score = 0, t: Score = 5, p: Score = 1 ) -> None: """Create a new game object. - + Parameters ---------- r: int or float diff --git a/axelrod/graph.py b/axelrod/graph.py index 6b91677b0..54aaee6e9 100644 --- a/axelrod/graph.py +++ b/axelrod/graph.py @@ -9,12 +9,12 @@ class Graph(object): """Weighted and directed graph class. - + This class is intended for the graph associated to a Markov process, since it gives easy access to the neighbors of a particular state. Vertices can be any hashable Python object. - + Initialize with a list of edges: [[node1, node2, weights], ...] Weights can be omitted for an undirected graph. @@ -22,7 +22,7 @@ class Graph(object): For efficiency, neighbors are cached in dictionaries. Undirected graphs are implemented as directed graphs in which every edge (s, t) has the opposite edge (t, s). - + Attributes ---------- directed: Boolean indicating whether the graph is directed @@ -31,7 +31,7 @@ class Graph(object): all tails to their edge weights (None means no weight) in_mapping: a dictionary mapping all tails to dictionaries that map all heads to their edge weights (none means to weight) - + Properties ---------- vertices: the set of vertices in the graph diff --git a/axelrod/load_data_.py b/axelrod/load_data_.py index ac29250fd..30e407566 100644 --- a/axelrod/load_data_.py +++ b/axelrod/load_data_.py @@ -56,7 +56,12 @@ def load_pso_tables(filename="pso_gambler.csv", directory="data"): rows = load_file(filename, directory) d = dict() for row in rows: - name, a, b, c, = str(row[0]), int(row[1]), int(row[2]), int(row[3]) + name, a, b, c, = ( + str(row[0]), + int(row[1]), + int(row[2]), + int(row[3]), + ) values = list(map(float, row[4:])) d[(name, int(a), int(b), int(c))] = values return d diff --git a/axelrod/result_set.py b/axelrod/result_set.py index ee6a515de..5f1fc8d8a 100644 --- a/axelrod/result_set.py +++ b/axelrod/result_set.py @@ -152,8 +152,10 @@ def _reshape_out( "DD to C count", "DD to D count", ] - self.state_to_action_distribution = self._build_state_to_action_distribution( - sum_per_player_opponent_df[columns] + self.state_to_action_distribution = ( + self._build_state_to_action_distribution( + sum_per_player_opponent_df[columns] + ) ) self.normalised_state_to_action_distribution = ( self._build_normalised_state_to_action_distribution() diff --git a/axelrod/strategies/_strategies.py b/axelrod/strategies/_strategies.py index 752e56f20..05c0408ed 100644 --- a/axelrod/strategies/_strategies.py +++ b/axelrod/strategies/_strategies.py @@ -142,6 +142,7 @@ GrudgerAlternator, OppositeGrudger, SoftGrudger, + SpitefulCC, ) from .grumpy import Grumpy from .handshake import Handshake @@ -467,6 +468,7 @@ SolutionB1, SolutionB5, SpitefulTitForTat, + SpitefulCC, Stalker, StochasticCooperator, StochasticWSLS, diff --git a/axelrod/strategies/cooperator.py b/axelrod/strategies/cooperator.py index 61d4fd4ca..1d1687664 100644 --- a/axelrod/strategies/cooperator.py +++ b/axelrod/strategies/cooperator.py @@ -59,8 +59,9 @@ def strategy(self, opponent: Player) -> Action: After 3 rounds, if opponent has not defected to a max history depth of 10, defect. """ - if self._has_played_enough_rounds_to_be_tricky() and self._opponents_has_cooperated_enough_to_be_tricky( - opponent + if ( + self._has_played_enough_rounds_to_be_tricky() + and self._opponents_has_cooperated_enough_to_be_tricky(opponent) ): return D return C diff --git a/axelrod/strategies/grudger.py b/axelrod/strategies/grudger.py index 41d1479c1..28dd51702 100644 --- a/axelrod/strategies/grudger.py +++ b/axelrod/strategies/grudger.py @@ -167,8 +167,7 @@ def __init__(self) -> None: self.grudge_memory = 0 def strategy(self, opponent: Player) -> Action: - """Begins by playing C, then plays D, D, D, D, C, C against a defection - """ + """Begins by playing C, then plays D, D, D, D, C, C against a defection""" if self.grudged: strategy = [D, D, D, C, C][self.grudge_memory] self.grudge_memory += 1 @@ -310,3 +309,35 @@ def strategy(self, opponent: Player) -> Action: def __repr__(self) -> str: return "%s: n=%s,d=%s,c=%s" % (self.name, self.n, self.d, self.c) + + +class SpitefulCC(Player): + """ + Behaves like Grudger after cooperating for 2 turns + + Names: + + - spiteful_cc: [Mathieu2015]_ + """ + + name = "SpitefulCC" + classifier = { + "memory_depth": float("inf"), # Long memory + "stochastic": False, + "long_run_time": False, + "inspects_source": False, + "manipulates_source": False, + "manipulates_state": False, + } + + @staticmethod + def strategy(opponent: Player) -> Action: + """ + Cooperates until the oponent defects, then defects forever. + Always cooperates twice at the start. + """ + if len(opponent.history) < 2: + return C + elif opponent.defections: + return D + return C diff --git a/axelrod/strategies/human.py b/axelrod/strategies/human.py index 20d921782..190590c12 100644 --- a/axelrod/strategies/human.py +++ b/axelrod/strategies/human.py @@ -118,12 +118,14 @@ def _status_messages(self): if PROMPT2 else lambda cli: [(token_toolbar, self._history_toolbar())] ) - print_statement = "{}Turn {}: {} played {}, opponent played {}".format( - linesep, - len(self.history), - self.human_name, - self.symbols[self.history[-1]], - self.symbols[self.history.coplays[-1]], + print_statement = ( + "{}Turn {}: {} played {}, opponent played {}".format( + linesep, + len(self.history), + self.human_name, + self.symbols[self.history[-1]], + self.symbols[self.history.coplays[-1]], + ) ) else: toolbar = None diff --git a/axelrod/strategies/lookerup.py b/axelrod/strategies/lookerup.py index 8bbed1e60..dd49f2371 100644 --- a/axelrod/strategies/lookerup.py +++ b/axelrod/strategies/lookerup.py @@ -535,7 +535,8 @@ def mutate(self): if r < self.mutation_probability: initial_actions[i] = initial_actions[i].flip() return self.create_new( - lookup_dict=lookup_dict, initial_actions=tuple(initial_actions), + lookup_dict=lookup_dict, + initial_actions=tuple(initial_actions), ) def crossover(self, other): diff --git a/axelrod/strategies/sequence_player.py b/axelrod/strategies/sequence_player.py index 58c7b6d3f..25bf70836 100644 --- a/axelrod/strategies/sequence_player.py +++ b/axelrod/strategies/sequence_player.py @@ -80,7 +80,7 @@ def __init__(self) -> None: class ThueMorseInverse(ThueMorse): - """ A player who plays the inverse of the Thue-Morse sequence. + """A player who plays the inverse of the Thue-Morse sequence. Names: diff --git a/axelrod/strategies/titfortat.py b/axelrod/strategies/titfortat.py index d3ab2d68d..c165b1c7d 100644 --- a/axelrod/strategies/titfortat.py +++ b/axelrod/strategies/titfortat.py @@ -307,13 +307,13 @@ def strategy(opponent: Player) -> Action: class OmegaTFT(Player): """OmegaTFT modifies Tit For Tat in two ways: - - checks for deadlock loops of alternating rounds of (C, D) and (D, C), - and attempting to break them - - uses a more sophisticated retaliation mechanism that is noise tolerant + - checks for deadlock loops of alternating rounds of (C, D) and (D, C), + and attempting to break them + - uses a more sophisticated retaliation mechanism that is noise tolerant - Names: + Names: - - OmegaTFT: [Slany2007]_ + - OmegaTFT: [Slany2007]_ """ name = "Omega TFT" @@ -394,7 +394,7 @@ class OriginalGradual(Player): Names: - Gradual: [Beaufils1997]_ - """ + """ name = "Original Gradual" classifier = { diff --git a/axelrod/tests/property.py b/axelrod/tests/property.py index d5d1919d9..3b674c71c 100644 --- a/axelrod/tests/property.py +++ b/axelrod/tests/property.py @@ -241,7 +241,12 @@ def spatial_tournaments( all_potential_edges = list(itertools.combinations(player_indices, 2)) all_potential_edges.extend([(i, i) for i in player_indices]) # Loops - edges = draw(lists(sampled_from(all_potential_edges), unique=True,)) + edges = draw( + lists( + sampled_from(all_potential_edges), + unique=True, + ) + ) # Ensure all players/nodes are connected: node_indices = sorted(set([node for edge in edges for node in edge])) @@ -311,7 +316,12 @@ def prob_end_spatial_tournaments( all_potential_edges = list(itertools.combinations(player_indices, 2)) all_potential_edges.extend([(i, i) for i in player_indices]) # Loops - edges = draw(lists(sampled_from(all_potential_edges), unique=True,)) + edges = draw( + lists( + sampled_from(all_potential_edges), + unique=True, + ) + ) # Ensure all players/nodes are connected: node_indices = sorted(set([node for edge in edges for node in edge])) diff --git a/axelrod/tests/strategies/test_axelrod_second.py b/axelrod/tests/strategies/test_axelrod_second.py index 5172eb89a..ec13529a3 100644 --- a/axelrod/tests/strategies/test_axelrod_second.py +++ b/axelrod/tests/strategies/test_axelrod_second.py @@ -274,7 +274,7 @@ def test_strategy3(self): def test_strategy4(self): """If score is greater than 2.25 either cooperate or defect, - if turn number <= 5; cooperate""" + if turn number <= 5; cooperate""" opponent = axl.MockPlayer(actions=[C] * 5) actions = [(C, C)] * 5 @@ -304,8 +304,8 @@ def test_strategy5(self): ) def test_strategy6(self): - """ Given score per turn is greater than 2.25, - Tranquilizer will never defect twice in a row""" + """Given score per turn is greater than 2.25, + Tranquilizer will never defect twice in a row""" opponent = axl.MockPlayer(actions=[C] * 6) actions = [(C, C)] * 4 + [(D, C), (C, C)] diff --git a/axelrod/tests/strategies/test_better_and_better.py b/axelrod/tests/strategies/test_better_and_better.py index 6b351fe7e..2499eb4a3 100644 --- a/axelrod/tests/strategies/test_better_and_better.py +++ b/axelrod/tests/strategies/test_better_and_better.py @@ -25,15 +25,21 @@ def test_strategy(self): """Tests that the strategy gives expected behaviour.""" expected_actions = [(D, D)] * 90 + [(C, D)] self.versus_test( - axl.Defector(), expected_actions=expected_actions, seed=6, + axl.Defector(), + expected_actions=expected_actions, + seed=6, ) expected_actions = [(D, C)] * 10 self.versus_test( - axl.Cooperator(), expected_actions=expected_actions, seed=8, + axl.Cooperator(), + expected_actions=expected_actions, + seed=8, ) expected_actions = [(D, D)] * 41 + [(C, D)] self.versus_test( - axl.Defector(), expected_actions=expected_actions, seed=13, + axl.Defector(), + expected_actions=expected_actions, + seed=13, ) expected_indices = [18, 39, 49, 67, 77, 116, 139, 142, 149] m = axl.Match((self.player(), axl.Defector()), turns=150, seed=111) diff --git a/axelrod/tests/strategies/test_finite_state_machines.py b/axelrod/tests/strategies/test_finite_state_machines.py index f7eab3029..fe491679b 100644 --- a/axelrod/tests/strategies/test_finite_state_machines.py +++ b/axelrod/tests/strategies/test_finite_state_machines.py @@ -452,7 +452,11 @@ def test_strategy(self): (5, D), (3, C), (5, C), - ] + [(7, C), (8, D), (6, C),] * 5 + ] + [ + (7, C), + (8, D), + (6, C), + ] * 5 self.transitions_test(state_and_actions) state_and_actions = ( diff --git a/axelrod/tests/strategies/test_gambler.py b/axelrod/tests/strategies/test_gambler.py index e9ab3b140..8683f9294 100755 --- a/axelrod/tests/strategies/test_gambler.py +++ b/axelrod/tests/strategies/test_gambler.py @@ -415,7 +415,9 @@ def test_vs_DCDDC2(self): (D, D), # different than above test ] self.versus_test( - axl.MockPlayer(opponent_actions), expected_actions=expected, seed=5, + axl.MockPlayer(opponent_actions), + expected_actions=expected, + seed=5, ) def test_vs_DCDDC3(self): @@ -580,7 +582,14 @@ class TestEvolvableGambler3(TestEvolvablePlayer): player_class = axl.EvolvableGambler parent_class = axl.Gambler parent_kwargs = ["lookup_dict"] - init_parameters = {"parameters": (3, 2, 1), "initial_actions": (C, C, C,)} + init_parameters = { + "parameters": (3, 2, 1), + "initial_actions": ( + C, + C, + C, + ), + } class TestEvolvableGambler4(TestEvolvablePlayer): @@ -591,7 +600,10 @@ class TestEvolvableGambler4(TestEvolvablePlayer): init_parameters = { "parameters": (2, 2, 2), "pattern": [random.random() for _ in range(64)], - "initial_actions": (C, C,), + "initial_actions": ( + C, + C, + ), } @@ -600,7 +612,10 @@ class TestEvolvableGambler4(TestEvolvablePlayer): axl.EvolvableGambler, pattern=tables[("PSO Gambler 2_2_2", 2, 2, 2)], parameters=(2, 2, 2), - initial_actions=(C, C,), + initial_actions=( + C, + C, + ), ) diff --git a/axelrod/tests/strategies/test_grudger.py b/axelrod/tests/strategies/test_grudger.py index 3ec1d6ac4..0f449cda6 100644 --- a/axelrod/tests/strategies/test_grudger.py +++ b/axelrod/tests/strategies/test_grudger.py @@ -305,3 +305,34 @@ def test_strategy(self): expected_actions=actions, init_kwargs={"n": 1, "d": 1, "c": 1}, ) + + +class TestSpitefulCC(TestPlayer): + + name = "SpitefulCC" + player = axl.SpitefulCC + expected_classifier = { + "memory_depth": float("inf"), # Long memory + "stochastic": False, + "makes_use_of": set(), + "long_run_time": False, + "inspects_source": False, + "manipulates_source": False, + "manipulates_state": False, + } + + def test_strategy(self): + # If opponent defects at any point then the player will defect forever. + # Cooperates for the first 2 turns. + opponent = axl.Cooperator() + actions = [(C, C)] * 20 + self.versus_test(opponent, expected_actions=actions) + + opponent = axl.Defector() + actions = [(C, D)] * 2 + [(D, D)] * 20 + self.versus_test(opponent, expected_actions=actions) + + opponent_actions = [D] * 20 + [C] * 20 + opponent = axl.MockPlayer(actions=opponent_actions) + actions = [(C, D)] * 2 + [(D, D)] * 18 + [(D, C)] * 20 + self.versus_test(opponent, expected_actions=actions) diff --git a/axelrod/tests/strategies/test_human.py b/axelrod/tests/strategies/test_human.py index a372b25ca..ffe35f5d0 100644 --- a/axelrod/tests/strategies/test_human.py +++ b/axelrod/tests/strategies/test_human.py @@ -72,8 +72,8 @@ def test_status_messages(self): self.assertEqual(actual_messages, expected_messages) human.history.append(C, C) - expected_print_message = "{}Turn 1: human played C, opponent played C".format( - linesep + expected_print_message = ( + "{}Turn 1: human played C, opponent played C".format(linesep) ) actual_messages = human._status_messages() self.assertEqual(actual_messages["print"], expected_print_message) diff --git a/axelrod/tests/strategies/test_lookerup.py b/axelrod/tests/strategies/test_lookerup.py index b3fdf6c9c..08dc27ab3 100755 --- a/axelrod/tests/strategies/test_lookerup.py +++ b/axelrod/tests/strategies/test_lookerup.py @@ -733,7 +733,10 @@ class TestEvolvableLookerUp4(TestEvolvablePlayer): init_parameters = { "parameters": (2, 2, 2), "pattern": "".join([random.choice(("C", "D")) for _ in range(64)]), - "initial_actions": (C, C,), + "initial_actions": ( + C, + C, + ), } @@ -743,7 +746,10 @@ class TestEvolvableLookerUp5(TestEvolvablePlayer): parent_class = axl.LookerUp parent_kwargs = ["lookup_dict", "initial_actions"] init_parameters = { - "initial_actions": (C, C,), + "initial_actions": ( + C, + C, + ), "lookup_dict": { ((C, C), (C,), ()): C, ((C, C), (D,), ()): D, diff --git a/axelrod/tests/strategies/test_meta.py b/axelrod/tests/strategies/test_meta.py index 3cb2c8241..a4c66448f 100644 --- a/axelrod/tests/strategies/test_meta.py +++ b/axelrod/tests/strategies/test_meta.py @@ -662,7 +662,7 @@ def classifier_test(self, expected_class_classifier=None): pass def test_strategy(self): - actions = [(C, C), (C, D), (D, C), (D, D), (D, C)] + actions = [(C, C), (C, D), (C, C), (D, D), (D, C)] self.versus_test( opponent=axl.Alternator(), expected_actions=actions, seed=11 ) diff --git a/axelrod/tests/strategies/test_titfortat.py b/axelrod/tests/strategies/test_titfortat.py index a13c06568..d262caddc 100644 --- a/axelrod/tests/strategies/test_titfortat.py +++ b/axelrod/tests/strategies/test_titfortat.py @@ -334,7 +334,10 @@ def test_strategy(self): self.versus_test( opponent, expected_actions=actions, - attrs={"calm_count": 0, "punish_count": 0,}, + attrs={ + "calm_count": 0, + "punish_count": 0, + }, ) opponent = axl.MockPlayer(actions=[D]) @@ -342,7 +345,10 @@ def test_strategy(self): self.versus_test( opponent, expected_actions=actions, - attrs={"calm_count": 0, "punish_count": 0,}, + attrs={ + "calm_count": 0, + "punish_count": 0, + }, ) opponent = axl.MockPlayer(actions=[D, C]) @@ -350,7 +356,10 @@ def test_strategy(self): self.versus_test( opponent, expected_actions=actions, - attrs={"calm_count": 2, "punish_count": 0,}, + attrs={ + "calm_count": 2, + "punish_count": 0, + }, ) opponent = axl.MockPlayer(actions=[D, C, C]) @@ -358,7 +367,10 @@ def test_strategy(self): self.versus_test( opponent, expected_actions=actions, - attrs={"calm_count": 1, "punish_count": 0,}, + attrs={ + "calm_count": 1, + "punish_count": 0, + }, ) opponent = axl.MockPlayer(actions=[D, C, D, C]) @@ -366,7 +378,10 @@ def test_strategy(self): self.versus_test( opponent, expected_actions=actions, - attrs={"calm_count": 0, "punish_count": 0,}, + attrs={ + "calm_count": 0, + "punish_count": 0, + }, ) opponent = axl.MockPlayer(actions=[D, C, D, C, C]) @@ -374,7 +389,10 @@ def test_strategy(self): self.versus_test( opponent, expected_actions=actions, - attrs={"calm_count": 0, "punish_count": 0,}, + attrs={ + "calm_count": 0, + "punish_count": 0, + }, ) opponent = axl.MockPlayer(actions=[D, C, D, C, C, C]) @@ -382,7 +400,10 @@ def test_strategy(self): self.versus_test( opponent, expected_actions=actions, - attrs={"calm_count": 0, "punish_count": 0,}, + attrs={ + "calm_count": 0, + "punish_count": 0, + }, ) opponent = axl.MockPlayer(actions=[D, C, D, C, C, C, D, C]) @@ -399,7 +420,10 @@ def test_strategy(self): self.versus_test( opponent, expected_actions=actions, - attrs={"calm_count": 2, "punish_count": 2,}, + attrs={ + "calm_count": 2, + "punish_count": 2, + }, ) opponent = axl.MockPlayer(actions=[D, C, D, C, C, D, D, D]) @@ -416,7 +440,10 @@ def test_strategy(self): self.versus_test( opponent, expected_actions=actions, - attrs={"calm_count": 2, "punish_count": 1,}, + attrs={ + "calm_count": 2, + "punish_count": 1, + }, ) opponent = axl.Defector() @@ -477,7 +504,10 @@ def test_strategy(self): self.versus_test( opponent, expected_actions=actions, - attrs={"calm_count": 2, "punish_count": 42,}, + attrs={ + "calm_count": 2, + "punish_count": 42, + }, ) def test_specific_set_of_results(self): @@ -490,7 +520,8 @@ def test_specific_set_of_results(self): both players cooperated in the previous round. """ mistrust_with_bug = axl.MemoryOnePlayer( - initial=D, four_vector=(1, 0, 0, 0), + initial=D, + four_vector=(1, 0, 0, 0), ) players = [ self.player(), diff --git a/axelrod/tests/unit/test_compute_finite_state_machine_memory.py b/axelrod/tests/unit/test_compute_finite_state_machine_memory.py index 8d46c2ced..fd697b26f 100644 --- a/axelrod/tests/unit/test_compute_finite_state_machine_memory.py +++ b/axelrod/tests/unit/test_compute_finite_state_machine_memory.py @@ -159,8 +159,7 @@ def test_tit_for_two_tat(self): self.assertEqual(get_memory_from_transitions(trans_dict), 2) def test_tit_for_five_tat(self): - """Analogous to tit for two tat above. - """ + """Analogous to tit for two tat above.""" transitions = ( (1, C, 1, C), (1, D, 2, C), @@ -227,8 +226,7 @@ def test_fortress_4(self): self.assertEqual(get_memory_from_transitions(trans_dict), 3) def test_complex_cooperator(self): - """Tests a cooperator with lots of states and transitions. - """ + """Tests a cooperator with lots of states and transitions.""" transitions = ( (0, C, 0, C), (0, D, 1, C), diff --git a/axelrod/tests/unit/test_fingerprint.py b/axelrod/tests/unit/test_fingerprint.py index 8f9e25b43..7660550cf 100644 --- a/axelrod/tests/unit/test_fingerprint.py +++ b/axelrod/tests/unit/test_fingerprint.py @@ -506,7 +506,9 @@ def test_serial_fingerprint(self): tf = TransitiveFingerprint(strategy) path = pathlib.Path("test_outputs/test_fingerprint.csv") tf.fingerprint( - repetitions=1, progress_bar=False, filename=axl_filename(path), + repetitions=1, + progress_bar=False, + filename=axl_filename(path), ) self.assertEqual(tf.data.shape, (50, 50)) diff --git a/axelrod/tests/unit/test_pickling.py b/axelrod/tests/unit/test_pickling.py index cec827819..dff35ba96 100644 --- a/axelrod/tests/unit/test_pickling.py +++ b/axelrod/tests/unit/test_pickling.py @@ -23,8 +23,10 @@ def strategy(self, opponent): return D -PointerToWrappedClassNotInStrategies = axl.strategy_transformers.FlipTransformer()( - axl.strategy_transformers.FlipTransformer()(MyDefector) +PointerToWrappedClassNotInStrategies = ( + axl.strategy_transformers.FlipTransformer()( + axl.strategy_transformers.FlipTransformer()(MyDefector) + ) ) diff --git a/axelrod/tests/unit/test_strategy_transformers.py b/axelrod/tests/unit/test_strategy_transformers.py index ba244d2fe..291f53c41 100644 --- a/axelrod/tests/unit/test_strategy_transformers.py +++ b/axelrod/tests/unit/test_strategy_transformers.py @@ -175,8 +175,7 @@ def test_doc(self): self.assertEqual(player.__doc__, transformer.__doc__) def test_cloning(self): - """Tests that Player.clone preserves the application of transformations. - """ + """Tests that Player.clone preserves the application of transformations.""" p1 = axl.Cooperator() p2 = FlipTransformer()(axl.Cooperator)() # Defector p3 = p2.clone() diff --git a/axelrod/tournament.py b/axelrod/tournament.py index 41d7d45f0..eba82edd5 100644 --- a/axelrod/tournament.py +++ b/axelrod/tournament.py @@ -97,7 +97,7 @@ def __init__( def setup_output(self, filename=None): """assign/create `filename` to `self`. If file should be deleted once - `play` is finished, assign a file descriptor. """ + `play` is finished, assign a file descriptor.""" temp_file_descriptor = None if filename is None: temp_file_descriptor, filename = mkstemp() diff --git a/docs/index.rst b/docs/index.rst index a0f933d12..f1f5c73ef 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -53,7 +53,7 @@ Count the number of available players:: >>> import axelrod as axl >>> len(axl.strategies) - 236 + 237 Create matches between two players:: @@ -111,4 +111,3 @@ Indices and tables * :ref:`genindex` * :ref:`modindex` * :ref:`search` - diff --git a/docs/tutorials/advanced/setting_a_seed.rst b/docs/tutorials/advanced/setting_a_seed.rst index cf3b16b45..119a259a9 100644 --- a/docs/tutorials/advanced/setting_a_seed.rst +++ b/docs/tutorials/advanced/setting_a_seed.rst @@ -53,7 +53,7 @@ To seed a tournament we also pass a seed to the tournament at creation time: >>> tournament = axl.Tournament(players, turns=5, repetitions=5, seed=seed) >>> results = tournament.play(processes=1) >>> tournament2 = axl.Tournament(players, turns=5, repetitions=5, seed=seed) - >>> results2 = tournament.play(processes=1) + >>> results2 = tournament2.play(processes=1) >>> results.ranked_names == results2.ranked_names True @@ -65,7 +65,7 @@ rankings, will be the same. >>> tournament = axl.Tournament(players, turns=5, repetitions=5, seed=201) >>> results = tournament.play(processes=2) >>> tournament2 = axl.Tournament(players, turns=5, repetitions=5, seed=201) - >>> results2 = tournament.play(processes=2) + >>> results2 = tournament2.play(processes=2) >>> results.ranked_names == results2.ranked_names True diff --git a/doctests.py b/doctests.py index 3ac377571..cb027d310 100644 --- a/doctests.py +++ b/doctests.py @@ -7,19 +7,19 @@ # Note loader and ignore are required arguments for unittest even if unused. def load_tests(loader, tests, ignore): """ - Locates and returns a collection of unittests in a TestSuite object - Parameters - ---------- - loader : - A required but unused parameter. - tests : - A unittest TestSuite object for collecting the needed test cases. - ignore : - A required but unused parameter. - Returns - ------- - tests : - A unittest TestSuite object that holds test cases. + Locates and returns a collection of unittests in a TestSuite object + Parameters + ---------- + loader : + A required but unused parameter. + tests : + A unittest TestSuite object for collecting the needed test cases. + ignore : + A required but unused parameter. + Returns + ------- + tests : + A unittest TestSuite object that holds test cases. """ for root, dirs, files in os.walk("."): for f in files: