public void JaggedArrayParseErrors(string x, string y) { var comparer = new JacobianComparison(defaultTolerance); comparer.CompareFiles(x, y); Assert.True(comparer.ViolationsHappened()); Assert.True(comparer.ParseError); }
public void GmmParseErrors(string fullGrad, string positions, string alphas, string means, string icfs) { var comparer = new JacobianComparison(defaultTolerance); comparer.CompareGmmFullAndPartGradients(fullGrad, new[] { positions, alphas, means, icfs }); Assert.True(comparer.ViolationsHappened()); Assert.True(comparer.ParseError); }
public void GmmDimensionMismatch() { var comparer = new JacobianComparison(defaultTolerance); comparer.CompareGmmFullAndPartGradients(cutGmm, new[] { positions, alphas, means, icfs }); Assert.True(comparer.ViolationsHappened()); Assert.False(comparer.ParseError); Assert.True(comparer.DimensionMismatch); }
public void ExpectedEquality(double x, double y, double tolerance) { var comparer = new JacobianComparison(tolerance); comparer.CompareNumbers(x, y, 0, 0); Assert.False(comparer.ViolationsHappened()); Assert.Equal(0, comparer.DifferenceViolationCount); Assert.Equal(1, comparer.NumberComparisonCount); }
public void InfinityZeroDifference() { var diff = JacobianComparison.Difference(double.PositiveInfinity, double.PositiveInfinity); Assert.Equal(0.0, diff); diff = JacobianComparison.Difference(double.NegativeInfinity, double.NegativeInfinity); Assert.Equal(0.0, diff); diff = JacobianComparison.Difference(double.PositiveInfinity, double.NegativeInfinity); Assert.NotEqual(0.0, diff); }
public void GoodGmmFailOnSmallTolerance() { var comparer = new JacobianComparison(1e-8); comparer.CompareGmmFullAndPartGradients(goodGmm, new[] { positions, alphas, means, icfs }); Assert.True(comparer.ViolationsHappened()); Assert.False(comparer.ParseError); Assert.False(comparer.DimensionMismatch); Assert.True(comparer.MaxDifference <= defaultTolerance); Assert.True(comparer.DifferenceViolationCount > 0); Assert.Equal(15, comparer.NumberComparisonCount); Assert.NotEmpty(comparer.DifferenceViolations); }
public void FarJaggedArraysViolationPositions() { var comparer = new JacobianComparison(defaultTolerance); comparer.CompareFiles(jaggedExtraWhitespace, jaggedErrors); Assert.True(comparer.ViolationsHappened()); Assert.False(comparer.ParseError); Assert.False(comparer.DimensionMismatch); Assert.False(comparer.MaxDifference <= defaultTolerance); Assert.Equal(8, comparer.DifferenceViolationCount); Assert.Equal(15, comparer.NumberComparisonCount); Assert.NotEmpty(comparer.DifferenceViolations); var expectedViolations = new[] { (0, 0), (1, 1), (3, 1), (0, 2), (2, 2), (0, 3), (2, 3), (4, 3) };
public void FarJaggedArraysFail(string x, string y, int expectedComparisons, double tolerance) { var comparer = new JacobianComparison(tolerance); comparer.CompareFiles(x, y); Assert.True(comparer.ViolationsHappened()); Assert.False(comparer.ParseError); Assert.False(comparer.DimensionMismatch); Assert.False(comparer.MaxDifference <= tolerance); Assert.True(comparer.DifferenceViolationCount > 0); Assert.Equal(expectedComparisons, comparer.NumberComparisonCount); Assert.NotEmpty(comparer.DifferenceViolations); }
public void NearJaggedArraysPass(string x, string y, int expectedComparisons) { var comparer = new JacobianComparison(defaultTolerance); comparer.CompareFiles(x, y); Assert.False(comparer.ViolationsHappened()); Assert.False(comparer.ParseError); Assert.False(comparer.DimensionMismatch); Assert.True(comparer.MaxDifference <= defaultTolerance); Assert.Equal(0, comparer.DifferenceViolationCount); Assert.Equal(expectedComparisons, comparer.NumberComparisonCount); Assert.Empty(comparer.DifferenceViolations); }
public void BadGmmFail() { var comparer = new JacobianComparison(defaultTolerance); comparer.CompareGmmFullAndPartGradients(badGmm, new[] { positions, alphas, means, icfs }); Assert.True(comparer.ViolationsHappened()); Assert.False(comparer.ParseError); Assert.False(comparer.DimensionMismatch); Assert.False(comparer.MaxDifference <= defaultTolerance); Assert.Equal(8, comparer.DifferenceViolationCount); Assert.Equal(15, comparer.NumberComparisonCount); Assert.NotEmpty(comparer.DifferenceViolations); for (int i = 0; i < 15; i += 2) { Assert.Contains((0, i), comparer.DifferenceViolations); } for (int i = 1; i < 15; i += 2) { Assert.DoesNotContain((0, i), comparer.DifferenceViolations); } }
public void DifferenceIsRelativeOutsideZeroVicinity(double x, double y) { Assert.Equal(JacobianComparison.Difference(x, y), Math.Abs(x - y) / (Math.Abs(x) + Math.Abs(y))); }
public void DifferenceIsAbsoluteInZeroVicinity(double x, double y) { Assert.Equal(JacobianComparison.Difference(x, y), Math.Abs(x - y)); }