diff --git a/test/Microsoft.ML.TestFramework/BaseTestBaseline.cs b/test/Microsoft.ML.TestFramework/BaseTestBaseline.cs index f4443f6fc9..614166c904 100644 --- a/test/Microsoft.ML.TestFramework/BaseTestBaseline.cs +++ b/test/Microsoft.ML.TestFramework/BaseTestBaseline.cs @@ -517,12 +517,12 @@ private bool GetNumbersFromFile(ref string firstString, ref string secondString, if (firstCollection.Count == secondCollection.Count) { - if(!MatchNumberWithTolerance(firstCollection, secondCollection, digitsOfPrecision)) + if (!MatchNumberWithTolerance(firstCollection, secondCollection, digitsOfPrecision)) { return false; } } - + firstString = MatchNumbers.Replace(firstString, "%Number%"); secondString = MatchNumbers.Replace(secondString, "%Number%"); return true; @@ -551,14 +551,20 @@ private bool MatchNumberWithTolerance(MatchCollection firstCollection, MatchColl // would fail the inRange == true check, but would suceed the following, and we doconsider those two numbers // (1.82844949 - 1.8284502) = -0.00000071 + double delta2 = 0; if (!inRange) { - delta = Math.Round(f1 - f2, digitsOfPrecision); - inRange = delta >= -allowedVariance && delta <= allowedVariance; + delta2 = Math.Round(f1 - f2, digitsOfPrecision); + inRange = delta2 >= -allowedVariance && delta2 <= allowedVariance; } - if(!inRange) + if (!inRange) { + Fail(_allowMismatch, $"Output and baseline mismatch at line {i}." + Environment.NewLine + + $"Values to compare are {firstCollection[i]} and {secondCollection[i]}" + Environment.NewLine + + $"\t AllowedVariance: {allowedVariance}" + Environment.NewLine + + $"\t delta: {delta}" + Environment.NewLine + + $"\t delta2: {delta2}" + Environment.NewLine); return false; } }