Skip to content

Commit

Permalink
Run black. (#1400)
Browse files Browse the repository at this point in the history
This is a PR to #1399 just
to check if running an updated version of black (22.1.0) fixes the CI.
  • Loading branch information
drvinceknight authored Mar 14, 2022
1 parent 64fa2be commit a72e44b
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 12 deletions.
5 changes: 4 additions & 1 deletion axelrod/compute_finite_state_machine_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ def get_accessible_transitions(
if trans.state in accessible_states:
accessible_transitions[
(trans.state, trans.last_opponent_action)
] = (trans.next_state, trans.next_action)
] = (
trans.next_state,
trans.next_action,
)

return accessible_transitions

Expand Down
2 changes: 1 addition & 1 deletion axelrod/fingerprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def _create_points(step: float, progress_bar: bool = True) -> List[Point]:
num = int((1 / step) // 1) + 1

if progress_bar:
p_bar = tqdm.tqdm(total=num ** 2, desc="Generating points")
p_bar = tqdm.tqdm(total=num**2, desc="Generating points")

points = []
for x in np.linspace(0, 1, num):
Expand Down
4 changes: 2 additions & 2 deletions axelrod/random_.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def randint(self, *args, **kwargs):
return self._random.randint(*args, **kwargs)

def random_seed_int(self) -> int:
return self.randint(low=0, high=2 ** 32 - 1, dtype="uint64")
return self.randint(low=0, high=2**32 - 1, dtype="uint64")

def choice(self, *args, **kwargs):
return self._random.choice(*args, **kwargs)
Expand Down Expand Up @@ -132,7 +132,7 @@ def _fill_ints(self):
# Generate more random values. Store as a list since generators
# cannot be pickled.
self._ints = self._random_generator.randint(
low=0, high=2 ** 32 - 1, size=self._batch_size, dtype="uint64"
low=0, high=2**32 - 1, size=self._batch_size, dtype="uint64"
)
self._index = 0

Expand Down
12 changes: 6 additions & 6 deletions axelrod/strategies/hmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def _normalize_parameters(
emission_probabilities = list(map(float, emission_probabilities))
num_states = len(emission_probabilities)
if mutation_probability is None:
mutation_probability = 10 / (num_states ** 2)
mutation_probability = 10 / (num_states**2)
else:
mutation_probability = mutation_probability
return (
Expand Down Expand Up @@ -432,7 +432,7 @@ class with self.num_states.
entry is the initial_action.
"""

assert len(vector) == 2 * self.num_states ** 2 + self.num_states + 1
assert len(vector) == 2 * self.num_states**2 + self.num_states + 1

def deserialize(vector):
matrix = []
Expand All @@ -442,9 +442,9 @@ def deserialize(vector):
matrix.append(row)
return matrix

break_tc = self.num_states ** 2
break_td = 2 * self.num_states ** 2
break_ep = 2 * self.num_states ** 2 + self.num_states
break_tc = self.num_states**2
break_td = 2 * self.num_states**2
break_ep = 2 * self.num_states**2 + self.num_states
initial_state = 0
self.hmm = SimpleHMM(
deserialize(vector[0:break_tc]),
Expand All @@ -457,7 +457,7 @@ def deserialize(vector):

def create_vector_bounds(self):
"""Creates the bounds for the decision variables."""
vec_len = 2 * self.num_states ** 2 + self.num_states + 1
vec_len = 2 * self.num_states**2 + self.num_states + 1
lb = [0.0] * vec_len
ub = [1.0] * vec_len
return lb, ub
Expand Down
2 changes: 1 addition & 1 deletion axelrod/tests/strategies/test_hmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ def test_vector_to_instance(self):

def test_create_vector_bounds(self):
num_states = 4
size = 2 * num_states ** 2 + num_states + 1
size = 2 * num_states**2 + num_states + 1

player = self.player_class(num_states=num_states, seed=1)
lb, ub = player.create_vector_bounds()
Expand Down
2 changes: 1 addition & 1 deletion axelrod/tests/strategies/test_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def test_clone(self):
player2 = player1.clone()
turns = 50
for op in [axl.Cooperator(), axl.Defector(), axl.TitForTat()]:
seed = random.randint(0, 10 ** 6)
seed = random.randint(0, 10**6)
for p in [player1, player2]:
m = axl.Match((p, op), turns=turns, reset=True, seed=seed)
m.play()
Expand Down

0 comments on commit a72e44b

Please sign in to comment.