Commit be74ad62 authored by Bas Nijholt's avatar Bas Nijholt
Browse files

round the losses to 12 digits to make them equal

Then equal losses will be sorted on x-coordinates.
parent c589a2f6
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -563,8 +563,13 @@ class Learner1D(BaseLearner):
        def finite_loss(loss, xs):
            # If the loss is infinite we return the
            # distance between the two points.
            return (loss if not math.isinf(loss)
                    else (xs[1] - xs[0]) / self._scale[0])
            if math.isinf(loss):
                loss = (xs[1] - xs[0]) / self._scale[0]

            # We round the loss to 12 digits such that losses
            # are equal up to numerical precision will be considered
            # equal.
            return round(loss, ndigits=12)

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