Skip to content

Commit 37f658e

Browse files
authored
Merge pull request #1292 from Axelrod-Python/1252
Suppress expected numpy warnings
2 parents 7a887ea + 66cbbfa commit 37f658e

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

axelrod/result_set.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import csv
33
import itertools
44
from multiprocessing import cpu_count
5+
import warnings
56

67
import numpy as np
78
import tqdm
@@ -405,12 +406,14 @@ def _build_initial_cooperation_count(self, initial_cooperation_count_series):
405406

406407
@update_progress_bar
407408
def _build_normalised_cooperation(self):
408-
normalised_cooperation = [
409-
list(np.nan_to_num(row))
410-
for row in np.array(self.cooperation)
411-
/ sum(map(np.array, self.match_lengths))
412-
]
413-
return normalised_cooperation
409+
with warnings.catch_warnings():
410+
warnings.simplefilter("ignore")
411+
normalised_cooperation = [
412+
list(np.nan_to_num(row))
413+
for row in np.array(self.cooperation)
414+
/ sum(map(np.array, self.match_lengths))
415+
]
416+
return normalised_cooperation
414417

415418
@update_progress_bar
416419
def _build_initial_cooperation_rate(self, interactions_series):
@@ -420,10 +423,12 @@ def _build_initial_cooperation_rate(self, interactions_series):
420423
for player_index in range(self.num_players)
421424
]
422425
)
423-
initial_cooperation_rate = list(
424-
np.nan_to_num(np.array(self.initial_cooperation_count) / interactions_array)
425-
)
426-
return initial_cooperation_rate
426+
with warnings.catch_warnings():
427+
warnings.simplefilter("ignore")
428+
initial_cooperation_rate = list(
429+
np.nan_to_num(np.array(self.initial_cooperation_count) / interactions_array)
430+
)
431+
return initial_cooperation_rate
427432

428433
@update_progress_bar
429434
def _build_ranking(self):

0 commit comments

Comments
 (0)