From 986891a7e3a37f8d41733c41e303fd1dd9d4a099 Mon Sep 17 00:00:00 2001 From: Chris Twiner Date: Wed, 10 Apr 2024 14:45:15 +0200 Subject: [PATCH] #787 - tests have ordering and precision issues when run on clusters - inifinity protection --- .../functions/DoubleBehaviourUtils.scala | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/dataset/src/test/scala/frameless/functions/DoubleBehaviourUtils.scala b/dataset/src/test/scala/frameless/functions/DoubleBehaviourUtils.scala index 29ecdfed..e43a7cd8 100644 --- a/dataset/src/test/scala/frameless/functions/DoubleBehaviourUtils.scala +++ b/dataset/src/test/scala/frameless/functions/DoubleBehaviourUtils.scala @@ -21,13 +21,17 @@ object DoubleBehaviourUtils { case null => None case d: Double => nanHandler(d).map { d => - BigDecimal(d).setScale( - 6, - if (d > 0) - BigDecimal.RoundingMode.FLOOR - else - BigDecimal.RoundingMode.CEILING - ) + if (d == Double.NegativeInfinity || d == Double.PositiveInfinity) + BigDecimal("1000000.000000") * (if (d == Double.PositiveInfinity) 1 + else -1) + else + BigDecimal(d).setScale( + 6, + if (d > 0) + BigDecimal.RoundingMode.FLOOR + else + BigDecimal.RoundingMode.CEILING + ) } case _ => ??? }