Skip to content

Suppress expected numpy warnings #1292

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

Merged
merged 1 commit into from
Mar 13, 2020
Merged
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
25 changes: 15 additions & 10 deletions axelrod/result_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import csv
import itertools
from multiprocessing import cpu_count
import warnings

import numpy as np
import tqdm
Expand Down Expand Up @@ -405,12 +406,14 @@ def _build_initial_cooperation_count(self, initial_cooperation_count_series):

@update_progress_bar
def _build_normalised_cooperation(self):
normalised_cooperation = [
list(np.nan_to_num(row))
for row in np.array(self.cooperation)
/ sum(map(np.array, self.match_lengths))
]
return normalised_cooperation
with warnings.catch_warnings():
warnings.simplefilter("ignore")
normalised_cooperation = [
list(np.nan_to_num(row))
for row in np.array(self.cooperation)
/ sum(map(np.array, self.match_lengths))
]
return normalised_cooperation

@update_progress_bar
def _build_initial_cooperation_rate(self, interactions_series):
Expand All @@ -420,10 +423,12 @@ def _build_initial_cooperation_rate(self, interactions_series):
for player_index in range(self.num_players)
]
)
initial_cooperation_rate = list(
np.nan_to_num(np.array(self.initial_cooperation_count) / interactions_array)
)
return initial_cooperation_rate
with warnings.catch_warnings():
warnings.simplefilter("ignore")
initial_cooperation_rate = list(
np.nan_to_num(np.array(self.initial_cooperation_count) / interactions_array)
)
return initial_cooperation_rate

@update_progress_bar
def _build_ranking(self):
Expand Down