Skip to content

Commit d1e3db2

Browse files
committed
Changes following PR review
1 parent 95f2ed2 commit d1e3db2

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

axelrod/moran.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,11 @@ def __init__(
110110
given
111111
fitness_transformation:
112112
A function mapping a score to a (non-negative) float
113+
mutation_method:
114+
A string indicating if the mutation method should be between original types ("transition")
115+
or based on the player's mutation method, if present ("atomic").
113116
stop_on_fixation:
114-
A bool indicating if the process should stop on fixation.
117+
A bool indicating if the process should stop on fixation
115118
"""
116119
self.turns = turns
117120
self.prob_end = prob_end

axelrod/random_.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,8 @@ def randrange(a: int, b: int) -> int:
7373

7474
def random_vector(size):
7575
"""Create a random vector of values in [0, 1] that sums to 1."""
76-
vector = []
77-
s = 1
78-
for _ in range(size - 1):
79-
r = s * random.random()
80-
vector.append(r)
81-
s -= r
82-
vector.append(s)
83-
return vector
76+
vector = np.random.random(size)
77+
return vector / np.sum(vector)
8478

8579

8680
class Pdf(object):

axelrod/tests/strategies/test_hmm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ def test_vector_to_instance(self):
232232
num_states = 4
233233
vector = []
234234
for _ in range(2 * num_states):
235-
vector += random_vector(num_states)
235+
vector.extend(list(random_vector(num_states)))
236236
for _ in range(num_states + 1):
237237
vector.append(random.random())
238238
player = self.player_class(num_states=num_states)

0 commit comments

Comments
 (0)