Skip to content

adding more logging to failures. #1555

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 7, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions test/Microsoft.ML.TestFramework/BaseTestBaseline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
Expand Down