Skip to content

Commit 11a6f1c

Browse files
committed
A few minor updates following some additional review
1 parent b0e00fe commit 11a6f1c

File tree

7 files changed

+11
-13
lines changed

7 files changed

+11
-13
lines changed

axelrod/evolvable_player.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def overwrite_init_kwargs(self, **kwargs):
3535
def create_new(self, **kwargs):
3636
"""Creates a new variant with parameters overwritten by kwargs. This differs from
3737
cloning the Player because it propagates a seed forward, and is intended to be
38-
used in my the mutation and crossover methods."""
38+
used by the mutation and crossover methods."""
3939
init_kwargs = self.init_kwargs.copy()
4040
init_kwargs.update(kwargs)
4141
# Propagate seed forward for reproducibility.

axelrod/player.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,7 @@ def _post_init(self):
118118
pass
119119

120120
def _post_transform(self):
121-
"""Overwrite this function if you need to do a post-transform, post-init
122-
modification."""
121+
"""Handles post transform tasks such as further reclassifying."""
123122
# Reclassify strategy post __init__, if needed.
124123
for (reclassifier, args, kwargs) in self._reclassifiers:
125124
self.classifier = reclassifier(self.classifier, *args, **kwargs)

axelrod/random_.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@ def random_flip(self, action: Action, threshold: float) -> Action:
8484
return action
8585

8686
def randrange(self, a: int, b: int) -> int:
87-
"""Python 2 / 3 compatible randrange. Returns a random integer uniformly
88-
between a and b (inclusive)"""
87+
"""Returns a random integer uniformly between a and b: [a, b)."""
8988
c = b - a
9089
r = c * self.random()
9190
return a + int(r)

axelrod/strategies/finite_state_machines.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ def __init__(
114114
initial_state: int = 1,
115115
initial_action: Action = C
116116
) -> None:
117-
# super().__init__()
118117
Player.__init__(self)
119118
self.initial_state = initial_state
120119
self.initial_action = initial_action

axelrod/strategies/meta.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def update_histories(self, coplay):
104104
# As a sanity check, look for at least one reclassifier, otherwise
105105
# this try-except clause could hide a bug.
106106
if len(self._reclassifiers) == 0:
107-
raise TypeError("MetaClass update_histories issue, expected a transformer.")
107+
raise TypeError("MetaClass update_histories issue, expected a reclassifier.")
108108
# Otherwise just update with C always, so at least the histories have the
109109
# expected length.
110110
for player in self.team:
@@ -223,9 +223,6 @@ class MetaWinnerEnsemble(MetaWinner):
223223

224224
name = "Meta Winner Ensemble"
225225

226-
def __init__(self, team=None):
227-
super().__init__(team=team)
228-
229226
def _post_init(self):
230227
super()._post_init()
231228
team = list(t.__class__ for t in self.team)

axelrod/strategies/rand.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def strategy(self, opponent: Player) -> Action:
4444
return self._random.random_choice(self.p)
4545

4646
def _post_init(self):
47+
super()._post_init()
4748
if self.p in [0, 1]:
4849
self.classifier["stochastic"] = False
4950
# Avoid calls to _random, if strategy is deterministic

axelrod/tests/unit/test_tournament.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -735,22 +735,25 @@ def test_write_to_csv_without_results(self):
735735
@settings(max_examples=5, deadline=None)
736736
def test_seeding_equality(self, seed):
737737
"""Tests that a tournament with a given seed will return the
738-
same results each time."""
738+
same results each time. This specifically checks when running using
739+
multiple cores so as to confirm that
740+
https://github.com/Axelrod-Python/Axelrod/issues/1277
741+
is fixed."""
739742
rng = axl.RandomGenerator(seed=seed)
740743
players = [axl.Random(rng.random()) for _ in range(8)]
741744
tournament1 = axl.Tournament(
742745
name=self.test_name,
743746
players=players,
744747
game=self.game,
745-
turns=3,
748+
turns=10,
746749
repetitions=100,
747750
seed=seed
748751
)
749752
tournament2 = axl.Tournament(
750753
name=self.test_name,
751754
players=players,
752755
game=self.game,
753-
turns=3,
756+
turns=10,
754757
repetitions=100,
755758
seed=seed
756759
)

0 commit comments

Comments
 (0)