Exemplo n.º 1
0
        public void RebaseTest()
        {
            // newBasis is null
            {
                var cloud = TestableCloud00.Get().Cloud;

                string parameterName = "newBasis";

                ArgumentExceptionAssert.Throw(
                    () =>
                {
                    cloud.Rebase(null);
                },
                    expectedType: typeof(ArgumentNullException),
                    expectedPartialMessage:
                    ArgumentExceptionAssert.NullPartialMessage,
                    expectedParameterName: parameterName);
            }

            // newBasis must have the same dimension of this instance
            {
                var STR_EXCEPT_PAR_BASES_MUST_SHARE_DIMENSION =
                    ImplementationServices.GetResourceString(
                        "STR_EXCEPT_PAR_BASES_MUST_SHARE_DIMENSION");

                var cloud = TestableCloud00.Get().Cloud;

                string parameterName = "newBasis";

                ArgumentExceptionAssert.Throw(
                    () =>
                {
                    cloud.Rebase(Basis.Standard(cloud.Coordinates.NumberOfColumns + 1));
                },
                    expectedType: typeof(ArgumentOutOfRangeException),
                    expectedPartialMessage:
                    STR_EXCEPT_PAR_BASES_MUST_SHARE_DIMENSION,
                    expectedParameterName: parameterName);
            }

            CloudTest.Rebase.Succeed(
                TestableCloud00.Get());
        }
Exemplo n.º 2
0
        public void GetPrincipalProjectionsTest()
        {
            var cloud = TestableCloud00.Get().Cloud;

            var principalProjections = cloud.GetPrincipalProjections();

            DoubleMatrixAssert.AreEqual(
                expected: cloud.Basis.GetBasisMatrix(),
                actual: principalProjections.ActiveCloud.Basis.GetBasisMatrix(),
                delta: CloudTest.Accuracy);

            DoubleMatrixAssert.AreEqual(
                expected: cloud.Coordinates,
                actual: principalProjections.ActiveCloud.Coordinates,
                delta: CloudTest.Accuracy);

            DoubleMatrixAssert.AreEqual(
                expected: cloud.Weights,
                actual: principalProjections.ActiveCloud.Weights,
                delta: CloudTest.Accuracy);
        }
Exemplo n.º 3
0
 public void StandardizeTest()
 {
     CloudTest.Standardize.Succeed(
         TestableCloud00.Get());
 }
Exemplo n.º 4
0
 public void CentredTest()
 {
     CloudTest.Center.Succeed(
         TestableCloud00.Get());
 }
Exemplo n.º 5
0
 public void CovarianceTest()
 {
     CloudTest.Covariance.Succeed(
         TestableCloud00.Get());
 }
Exemplo n.º 6
0
 public void MeanTest()
 {
     CloudTest.Mean.Succeed(
         TestableCloud00.Get());
 }
Exemplo n.º 7
0
        public void GetVariancesTest()
        {
            // supplementaryVariables is null - DoubleMatrix
            {
                string parameterName = "supplementaryVariables";

                var cloud = TestableCloud00.Get().Cloud;

                ArgumentExceptionAssert.Throw(
                    () =>
                {
                    cloud.GetVariances((DoubleMatrix)null);
                },
                    expectedType: typeof(ArgumentNullException),
                    expectedPartialMessage:
                    ArgumentExceptionAssert.NullPartialMessage,
                    expectedParameterName: parameterName);
            }

            // supplementaryVariables is null - ReadOnlyDoubleMatrix
            {
                string parameterName = "supplementaryVariables";

                var cloud = TestableCloud00.Get().Cloud;

                ArgumentExceptionAssert.Throw(
                    () =>
                {
                    cloud.GetVariances((ReadOnlyDoubleMatrix)null);
                },
                    expectedType: typeof(ArgumentNullException),
                    expectedPartialMessage:
                    ArgumentExceptionAssert.NullPartialMessage,
                    expectedParameterName: parameterName);
            }

            // supplementaryVariables must have as number of rows the number of cloud points
            {
                var STR_EXCEPT_PAR_ROW_DIM_MUST_MATCH_INDIVIDUALS_COUNT =
                    ImplementationServices.GetResourceString(
                        "STR_EXCEPT_PAR_ROW_DIM_MUST_MATCH_INDIVIDUALS_COUNT");

                string parameterName = "supplementaryVariables";

                var cloud = TestableCloud00.Get().Cloud;

                var supplementaryVariables =
                    DoubleMatrix.Dense(
                        cloud.Coordinates.NumberOfRows + 1,
                        10);

                ArgumentExceptionAssert.Throw(
                    () =>
                {
                    cloud.GetVariances(supplementaryVariables);
                },
                    expectedType: typeof(ArgumentOutOfRangeException),
                    expectedPartialMessage:
                    STR_EXCEPT_PAR_ROW_DIM_MUST_MATCH_INDIVIDUALS_COUNT,
                    expectedParameterName: parameterName);
            }

            // Valid input - DoubleMatrix
            {
                var cloud = TestableCloud00.Get().Cloud;

                var actual = cloud.GetVariances((DoubleMatrix)cloud.Coordinates);

                var cov_sa   = cloud.Covariance;
                var expected = DoubleMatrix.Dense(1, cloud.Coordinates.NumberOfColumns);
                for (int i = 0; i < expected.Count; i++)
                {
                    expected[i] = cov_sa[i, i];
                }

                DoubleMatrixAssert.AreEqual(
                    expected: expected,
                    actual: actual,
                    delta: CloudTest.Accuracy);
            }

            // Valid input - ReadOnlyDoubleMatrix
            {
                var cloud = TestableCloud00.Get().Cloud;

                var actual = cloud.GetVariances(cloud.Coordinates);

                var cov_sa   = cloud.Covariance;
                var expected = DoubleMatrix.Dense(1, cloud.Coordinates.NumberOfColumns);
                for (int i = 0; i < expected.Count; i++)
                {
                    expected[i] = cov_sa[i, i];
                }

                DoubleMatrixAssert.AreEqual(
                    expected: expected,
                    actual: actual,
                    delta: CloudTest.Accuracy);
            }
        }
Exemplo n.º 8
0
 public void BasisTest()
 {
     CloudTest.Basis.Succeed(
         TestableCloud00.Get());
 }
Exemplo n.º 9
0
 public void WeightsTest()
 {
     CloudTest.Weights.Succeed(
         TestableCloud00.Get());
 }
Exemplo n.º 10
0
 public void CoordinatesTest()
 {
     CloudTest.Coordinates.Succeed(
         TestableCloud00.Get());
 }