Skip to content

Commit

Permalink
chore: issue warning if nan values or infs are found
Browse files Browse the repository at this point in the history
  • Loading branch information
younesStrittmatter committed Sep 15, 2023
1 parent 32602f3 commit 6f6c55c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/autora/experimentalist/model_disagreement/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import itertools
import warnings
from typing import Iterable, List, Optional, Union

import numpy as np
Expand Down Expand Up @@ -90,8 +91,10 @@ def score_sample(
else:
disagreement = np.mean((y_a - y_b) ** 2, axis=1)

if np.isinf(disagreement).any() or np.isnan(disagreement).any():
warnings.warn('Found nan or inf values in model predictions, '
'setting disagreement there to 0')
disagreement[np.isinf(disagreement)] = 0

disagreement = np.nan_to_num(disagreement)

model_disagreement.append(disagreement)
Expand Down

0 comments on commit 6f6c55c

Please sign in to comment.