Skip to content

Commit be74ad6

Browse files
committed
round the losses to 12 digits to make them equal
Then equal losses will be sorted on x-coordinates.
1 parent c589a2f commit be74ad6

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

adaptive/learner/learner1D.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,8 +563,13 @@ def _ask_points_without_adding(self, n):
563563
def finite_loss(loss, xs):
564564
# If the loss is infinite we return the
565565
# distance between the two points.
566-
return (loss if not math.isinf(loss)
567-
else (xs[1] - xs[0]) / self._scale[0])
566+
if math.isinf(loss):
567+
loss = (xs[1] - xs[0]) / self._scale[0]
568+
569+
# We round the loss to 12 digits such that losses
570+
# are equal up to numerical precision will be considered
571+
# equal.
572+
return round(loss, ndigits=12)
568573

569574
quals = [(-finite_loss(loss, x), x, 1)
570575
for x, loss in self.losses_combined.items()]

0 commit comments

Comments
 (0)