Skip to content

Commit d575c32

Browse files
committed
only divide by mean whenever it's not zero
1 parent 34d37f7 commit d575c32

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

adaptive/learner/average_learner.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ def loss(self, real=True, *, n=None):
119119
return np.inf
120120
standard_error = self.std / sqrt(n)
121121
aloss = standard_error / self.atol
122-
rloss = standard_error / abs(self.mean) / self.rtol
122+
rloss = standard_error / self.rtol
123+
if self.mean != 0:
124+
rloss /= abs(self.mean)
123125
return max(aloss, rloss)
124126

125127
def _loss_improvement(self, n):

0 commit comments

Comments
 (0)