@@ -42,7 +42,7 @@ def _create_points(step: float, progress_bar: bool = True) -> List[Point]:
4242 num = int ((1 / step ) // 1 ) + 1
4343
4444 if progress_bar :
45- p_bar = tqdm .tqdm (total = num ** 2 , desc = "Generating points" )
45+ p_bar = tqdm .tqdm (total = num ** 2 , desc = "Generating points" )
4646
4747 points = []
4848 for x in np .linspace (0 , 1 , num ):
@@ -88,8 +88,8 @@ def _create_jossann(point: Point, probe: Any) -> Player:
8888
8989 if x + y >= 1 :
9090 joss_ann = DualTransformer ()(
91- JossAnnTransformer ((1 - x , 1 - y ))(
92- probe_class ) )(** init_kwargs )
91+ JossAnnTransformer ((1 - x , 1 - y ))(probe_class )
92+ )(** init_kwargs )
9393 else :
9494 joss_ann = JossAnnTransformer ((x , y ))(probe_class )(** init_kwargs )
9595 return joss_ann
@@ -177,7 +177,10 @@ def _generate_data(interactions: dict, points: list, edges: list) -> dict:
177177 """
178178 edge_scores = [
179179 np .mean (
180- [compute_final_score_per_turn (scores )[0 ] for scores in interactions [edge ]]
180+ [
181+ compute_final_score_per_turn (scores )[0 ]
182+ for scores in interactions [edge ]
183+ ]
181184 )
182185 for edge in edges
183186 ]
@@ -215,7 +218,9 @@ def _reshape_data(data: dict, points: list, size: int) -> np.ndarray:
215218
216219class AshlockFingerprint (object ):
217220 def __init__ (
218- self , strategy : Union [type , Player ], probe : Union [type , Player ] = axl .TitForTat
221+ self ,
222+ strategy : Union [type , Player ],
223+ probe : Union [type , Player ] = axl .TitForTat ,
219224 ) -> None :
220225 """
221226 Parameters
@@ -277,7 +282,7 @@ def fingerprint(
277282 processes : int = None ,
278283 filename : str = None ,
279284 progress_bar : bool = True ,
280- seed : int = None
285+ seed : int = None ,
281286 ) -> dict :
282287 """Build and play the spatial tournament.
283288
@@ -323,8 +328,11 @@ def fingerprint(
323328
324329 self .step = step
325330 self .spatial_tournament = axl .Tournament (
326- tourn_players , turns = turns , repetitions = repetitions , edges = edges ,
327- seed = seed
331+ tourn_players ,
332+ turns = turns ,
333+ repetitions = repetitions ,
334+ edges = edges ,
335+ seed = seed ,
328336 )
329337 self .spatial_tournament .play (
330338 build_results = False ,
@@ -432,7 +440,7 @@ def fingerprint(
432440 processes : int = None ,
433441 filename : str = None ,
434442 progress_bar : bool = True ,
435- seed : int = None
443+ seed : int = None ,
436444 ) -> np .array :
437445 """Creates a spatial tournament to run the necessary matches to obtain
438446 fingerprint data.
@@ -479,7 +487,7 @@ def fingerprint(
479487 turns = turns ,
480488 noise = noise ,
481489 repetitions = repetitions ,
482- seed = seed
490+ seed = seed ,
483491 )
484492 tournament .play (
485493 filename = filename ,
@@ -516,7 +524,9 @@ def analyse_cooperation_ratio(filename):
516524 opponent in each turn. The ith row corresponds to the ith opponent
517525 and the jth column the jth turn.
518526 """
519- did_c = np .vectorize (lambda actions : [int (action == "C" ) for action in actions ])
527+ did_c = np .vectorize (
528+ lambda actions : [int (action == "C" ) for action in actions ]
529+ )
520530
521531 cooperation_rates = {}
522532 df = dd .read_csv (filename )
@@ -525,7 +535,10 @@ def analyse_cooperation_ratio(filename):
525535 df = df [df ["Player index" ] == 0 ][["Opponent index" , "Actions" ]]
526536
527537 for _ , row in df .iterrows ():
528- opponent_index , player_history = row ["Opponent index" ], row ["Actions" ]
538+ opponent_index , player_history = (
539+ row ["Opponent index" ],
540+ row ["Actions" ],
541+ )
529542 if opponent_index in cooperation_rates :
530543 cooperation_rates [opponent_index ].append (did_c (player_history ))
531544 else :
@@ -590,7 +603,8 @@ def plot(
590603
591604 if display_names :
592605 plt .yticks (
593- range (len (self .opponents )), [str (player ) for player in self .opponents ]
606+ range (len (self .opponents )),
607+ [str (player ) for player in self .opponents ],
594608 )
595609 else :
596610 plt .yticks ([0 , len (self .opponents ) - 1 ], [0 , 1 ])
0 commit comments