Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run black. #1400

Merged
merged 1 commit into from
Mar 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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