Skip to content

Commit 562be02

Browse files
committedApr 8, 2020
Revert "Run black on all files"
This reverts commit 6e31d2a.
1 parent 6e31d2a commit 562be02

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+676
-762
lines changed
 

‎axelrod/compute_finite_state_machine_memory.py

+23-10
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ def __hash__(self):
4747

4848
def __eq__(self, other_memit) -> bool:
4949
"""In action and out actions are the same."""
50-
return self.in_act == other_memit.in_act and self.out_act == other_memit.out_act
50+
return (
51+
self.in_act == other_memit.in_act
52+
and self.out_act == other_memit.out_act
53+
)
5154

5255
def __lt__(self, other_memit) -> bool:
5356
return repr(self) < repr(other_memit)
@@ -107,10 +110,9 @@ def get_accessible_transitions(
107110
accessible_transitions = dict()
108111
for trans in transition_iterator(transitions):
109112
if trans.state in accessible_states:
110-
accessible_transitions[(trans.state, trans.last_opponent_action)] = (
111-
trans.next_state,
112-
trans.next_action,
113-
)
113+
accessible_transitions[
114+
(trans.state, trans.last_opponent_action)
115+
] = (trans.next_state, trans.next_action)
114116

115117
return accessible_transitions
116118

@@ -177,7 +179,9 @@ def get_memory_from_transitions(
177179
transitions = get_accessible_transitions(transitions, initial_state)
178180

179181
# Get the incoming actions for each state.
180-
incoming_action_by_state = defaultdict(set) # type: DefaultDict[int, Set[Action]]
182+
incoming_action_by_state = defaultdict(
183+
set
184+
) # type: DefaultDict[int, Set[Action]]
181185
for trans in transition_iterator(transitions):
182186
incoming_action_by_state[trans.next_state].add(trans.next_action)
183187

@@ -189,17 +193,23 @@ def get_memory_from_transitions(
189193
# That is to say that the opponent could do anything
190194
for out_action in all_actions:
191195
# More recent in action history
192-
starting_node = Memit(trans.next_action, trans.next_state, out_action)
196+
starting_node = Memit(
197+
trans.next_action, trans.next_state, out_action
198+
)
193199
# All incoming paths to current state
194200
for in_action in incoming_action_by_state[trans.state]:
195201
# Less recent in action history
196-
ending_node = Memit(in_action, trans.state, trans.last_opponent_action)
202+
ending_node = Memit(
203+
in_action, trans.state, trans.last_opponent_action
204+
)
197205
memit_edges[starting_node].add(ending_node)
198206

199207
all_memits = list(memit_edges.keys())
200208

201209
pair_nodes = set()
202-
pair_edges = defaultdict(set) # type: DefaultDict[MemitPair, Set[MemitPair]]
210+
pair_edges = defaultdict(
211+
set
212+
) # type: DefaultDict[MemitPair, Set[MemitPair]]
203213
# Loop through all pairs of memits.
204214
for x, y in [(x, y) for x in all_memits for y in all_memits]:
205215
if x == y and x.state == y.state:
@@ -226,7 +236,9 @@ def get_memory_from_transitions(
226236
next_action_by_memit = dict()
227237
for trans in transition_iterator(transitions):
228238
for in_action in incoming_action_by_state[trans.state]:
229-
memit_key = Memit(in_action, trans.state, trans.last_opponent_action)
239+
memit_key = Memit(
240+
in_action, trans.state, trans.last_opponent_action
241+
)
230242
next_action_by_memit[memit_key] = trans.next_action
231243

232244
# Calculate the longest path.
@@ -251,3 +263,4 @@ def get_memory_from_transitions(
251263
if len(next_action_set) == 1:
252264
return 0
253265
return 1
266+

‎axelrod/evolvable_player.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
class InsufficientParametersError(Exception):
99
"""Error indicating that insufficient parameters were specified to initialize an Evolvable Player."""
10-
1110
def __init__(self, *args):
1211
super().__init__(*args)
1312

@@ -39,7 +38,7 @@ def create_new(self, **kwargs):
3938
def serialize_parameters(self):
4039
"""Serialize parameters."""
4140
pickled = dumps(self.init_kwargs) # bytes
42-
s = base64.b64encode(pickled).decode("utf8") # string
41+
s = base64.b64encode(pickled).decode('utf8') # string
4342
return s
4443

4544
@classmethod

0 commit comments

Comments
 (0)
Please sign in to comment.