예제 #1
0
        public void JaggedArrayParseErrors(string x, string y)
        {
            var comparer = new JacobianComparison(defaultTolerance);

            comparer.CompareFiles(x, y);
            Assert.True(comparer.ViolationsHappened());
            Assert.True(comparer.ParseError);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        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);
        }
예제 #6
0
        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);
        }
예제 #7
0
        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) };
예제 #8
0
        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);
        }
예제 #9
0
        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);
        }
예제 #10
0
        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);
            }
        }
예제 #11
0
 public void DifferenceIsRelativeOutsideZeroVicinity(double x, double y)
 {
     Assert.Equal(JacobianComparison.Difference(x, y), Math.Abs(x - y) / (Math.Abs(x) + Math.Abs(y)));
 }
예제 #12
0
 public void DifferenceIsAbsoluteInZeroVicinity(double x, double y)
 {
     Assert.Equal(JacobianComparison.Difference(x, y), Math.Abs(x - y));
 }