@@ -72,24 +72,23 @@ def __init__(self, filename,
72
72
73
73
out = self ._compute_tasks (tasks = dask_tasks , processes = processes )
74
74
75
- self ._reshape_out (out )
75
+ self ._reshape_out (* out )
76
76
77
77
if progress_bar :
78
78
self .progress_bar .close ()
79
79
80
- def _reshape_out (self , out ):
80
+ def _reshape_out (self ,
81
+ mean_per_reps_player_opponent_df ,
82
+ sum_per_player_opponent_df ,
83
+ sum_per_player_repetition_df ,
84
+ normalised_scores_series ,
85
+ initial_cooperation_count_series ,
86
+ interactions_count_series ):
81
87
"""
82
88
Reshape the various pandas series objects to be of the required form and
83
89
set the corresponding attributes.
84
90
"""
85
91
86
- (mean_per_reps_player_opponent_df ,
87
- sum_per_player_opponent_df ,
88
- sum_per_player_repetition_df ,
89
- normalised_scores_series ,
90
- initial_cooperation_count_series ,
91
- interactions_count_series ) = out
92
-
93
92
self .payoffs = self ._build_payoffs (mean_per_reps_player_opponent_df ["Score per turn" ])
94
93
self .score_diffs = self ._build_score_diffs (mean_per_reps_player_opponent_df ["Score difference per turn" ])
95
94
self .match_lengths = self ._build_match_lengths (mean_per_reps_player_opponent_df ["Turns" ])
@@ -269,8 +268,8 @@ def _build_good_partner_matrix(self, good_partner_series):
269
268
# interactions.
270
269
row .append (0 )
271
270
else :
272
- row .append (good_partner_dict .get (( player_index ,
273
- opponent_index ), 0 ))
271
+ row .append (good_partner_dict .get (
272
+ ( player_index , opponent_index ), 0 ))
274
273
good_partner_matrix .append (row )
275
274
return good_partner_matrix
276
275
@@ -398,10 +397,9 @@ def _build_normalised_state_to_action_distribution(self):
398
397
@update_progress_bar
399
398
def _build_initial_cooperation_count (self , initial_cooperation_count_series ):
400
399
initial_cooperation_count_dict = initial_cooperation_count_series .to_dict ()
401
- initial_cooperation_count = [
402
- initial_cooperation_count_dict .get (player_index , 0 )
403
- for player_index in
404
- range (self .num_players )]
400
+ initial_cooperation_count = [initial_cooperation_count_dict .get (player_index , 0 )
401
+ for player_index in
402
+ range (self .num_players )]
405
403
return initial_cooperation_count
406
404
407
405
@update_progress_bar
@@ -564,10 +562,14 @@ def _build_tasks(self, df):
564
562
columns = ["Win" , "Score" ]
565
563
sum_per_player_repetition_task = adf .groupby (groups )[columns ].sum ()
566
564
567
- normalised_scores_task = adf .groupby (["Player index" ,
568
- "Repetition" ]
569
- )["Score per turn" ].mean ()
570
- initial_cooperation_count_task = adf .groupby (["Player index" ])["Initial cooperation" ].sum ()
565
+ groups = ["Player index" , "Repetition" ]
566
+ column = "Score per turn"
567
+ normalised_scores_task = adf .groupby (groups )[column ].mean ()
568
+
569
+
570
+ groups = ["Player index" ]
571
+ column = "Initial cooperation"
572
+ initial_cooperation_count_task = adf .groupby (groups )[column ].sum ()
571
573
interactions_count_task = adf .groupby ("Player index" )["Player index" ].count ()
572
574
573
575
0 commit comments