Skip to content

Commit d8402cd

Browse files
authored
adding more logging to failures. (#1555)
* adding more logging to failures.
1 parent 70524d3 commit d8402cd

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

test/Microsoft.ML.TestFramework/BaseTestBaseline.cs

+11-5
Original file line numberDiff line numberDiff line change
@@ -517,12 +517,12 @@ private bool GetNumbersFromFile(ref string firstString, ref string secondString,
517517

518518
if (firstCollection.Count == secondCollection.Count)
519519
{
520-
if(!MatchNumberWithTolerance(firstCollection, secondCollection, digitsOfPrecision))
520+
if (!MatchNumberWithTolerance(firstCollection, secondCollection, digitsOfPrecision))
521521
{
522522
return false;
523523
}
524524
}
525-
525+
526526
firstString = MatchNumbers.Replace(firstString, "%Number%");
527527
secondString = MatchNumbers.Replace(secondString, "%Number%");
528528
return true;
@@ -551,14 +551,20 @@ private bool MatchNumberWithTolerance(MatchCollection firstCollection, MatchColl
551551
// would fail the inRange == true check, but would suceed the following, and we doconsider those two numbers
552552
// (1.82844949 - 1.8284502) = -0.00000071
553553

554+
double delta2 = 0;
554555
if (!inRange)
555556
{
556-
delta = Math.Round(f1 - f2, digitsOfPrecision);
557-
inRange = delta >= -allowedVariance && delta <= allowedVariance;
557+
delta2 = Math.Round(f1 - f2, digitsOfPrecision);
558+
inRange = delta2 >= -allowedVariance && delta2 <= allowedVariance;
558559
}
559560

560-
if(!inRange)
561+
if (!inRange)
561562
{
563+
Fail(_allowMismatch, $"Output and baseline mismatch at line {i}." + Environment.NewLine +
564+
$"Values to compare are {firstCollection[i]} and {secondCollection[i]}" + Environment.NewLine +
565+
$"\t AllowedVariance: {allowedVariance}" + Environment.NewLine +
566+
$"\t delta: {delta}" + Environment.NewLine +
567+
$"\t delta2: {delta2}" + Environment.NewLine);
562568
return false;
563569
}
564570
}

0 commit comments

Comments
 (0)