Exemple #1
0
            /// <summary>
            /// Tests that the
            /// <see cref="PrincipalProjections.ActiveCloud"/>
            /// property has
            /// been properly implemented.
            public static void Succeed(
                TestablePrincipalProjections testablePrincipalProjections)
            {
                var principalProjections =
                    testablePrincipalProjections.PrincipalProjections;

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

                DoubleMatrixAssert.AreEqual(
                    expected: testablePrincipalProjections
                    .ActiveCloud.Coordinates,
                    actual: principalProjections
                    .ActiveCloud.Coordinates,
                    delta: PrincipalProjectionsTest.Accuracy);

                DoubleMatrixAssert.AreEqual(
                    expected: testablePrincipalProjections
                    .ActiveCloud.Weights,
                    actual: principalProjections
                    .ActiveCloud.Weights,
                    delta: PrincipalProjectionsTest.Accuracy);
            }
Exemple #2
0
                /// <summary>
                /// Tests that the
                /// <see cref="PrincipalProjections.RegressSupplementaryVariables"/>
                /// method fails when supplementaryVariables is null.
                public static void SupplementaryVariablesIsNull(
                    TestablePrincipalProjections testablePrincipalProjections)
                {
                    var principalProjections =
                        testablePrincipalProjections.PrincipalProjections;

                    string parameterName = "supplementaryVariables";

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

                    ArgumentExceptionAssert.Throw(
                        () =>
                    {
                        principalProjections.RegressSupplementaryVariables(
                            (ReadOnlyDoubleMatrix)null);
                    },
                        expectedType: typeof(ArgumentNullException),
                        expectedPartialMessage:
                        ArgumentExceptionAssert.NullPartialMessage,
                        expectedParameterName: parameterName);
                }
Exemple #3
0
                /// <summary>
                /// Tests that the
                /// <see cref="PrincipalProjections.RegressSupplementaryVariables"/>
                /// method fails when supplementaryVariables has not
                /// the expected number of rows.
                public static void SupplementaryVariablesHasWrongNumberOfRows(
                    TestablePrincipalProjections testablePrincipalProjections)
                {
                    var principalProjections =
                        testablePrincipalProjections.PrincipalProjections;

                    var STR_EXCEPT_GDA_ROWS_NOT_EQUAL_TO_ACTIVE_POINTS =
                        ImplementationServices.GetResourceString(
                            "STR_EXCEPT_GDA_ROWS_NOT_EQUAL_TO_ACTIVE_POINTS");

                    string parameterName = "supplementaryVariables";

                    DoubleMatrix supplementaryVariables =
                        DoubleMatrix.Dense(
                            principalProjections.ActiveCloud.Coordinates.NumberOfRows + 1,
                            2);

                    ArgumentExceptionAssert.Throw(
                        () =>
                    {
                        principalProjections.RegressSupplementaryVariables(
                            supplementaryVariables);
                    },
                        expectedType: typeof(ArgumentOutOfRangeException),
                        expectedPartialMessage:
                        STR_EXCEPT_GDA_ROWS_NOT_EQUAL_TO_ACTIVE_POINTS,
                        expectedParameterName: parameterName);
                }
Exemple #4
0
                /// <summary>
                /// Tests that the
                /// <see cref="PrincipalProjections.LocateSupplementaryPoints"/>
                /// method fails when activeCoordinates has not
                /// the expected number of columns.
                public static void ActiveCoordinatesHasWrongNumberOfColumns(
                    TestablePrincipalProjections testablePrincipalProjections)
                {
                    var principalProjections =
                        testablePrincipalProjections.PrincipalProjections;

                    var STR_EXCEPT_GDA_COLUMNS_NOT_EQUAL_TO_ACTIVE_VARIABLES =
                        ImplementationServices.GetResourceString(
                            "STR_EXCEPT_GDA_COLUMNS_NOT_EQUAL_TO_ACTIVE_VARIABLES");

                    string parameterName = "activeCoordinates";

                    DoubleMatrix activeCoordinates =
                        DoubleMatrix.Dense(
                            2,
                            principalProjections.ActiveCloud.Coordinates.NumberOfColumns + 1);

                    ArgumentExceptionAssert.Throw(
                        () =>
                    {
                        principalProjections.LocateSupplementaryPoints(
                            activeCoordinates);
                    },
                        expectedType: typeof(ArgumentOutOfRangeException),
                        expectedPartialMessage:
                        STR_EXCEPT_GDA_COLUMNS_NOT_EQUAL_TO_ACTIVE_VARIABLES,
                        expectedParameterName: parameterName);
                }
Exemple #5
0
 /// <summary>Initializes a new instance of the
 /// <see cref="TestableMultipleCorrespondence"/>
 /// class.</summary>
 /// <param name="multipleCorrespondence">
 /// The multiple correspondence to test.</param>
 /// <param name="individuals">The expected individuals.</param>
 /// <param name="categories">The expected categories.</param>
 public TestableMultipleCorrespondence(
     MultipleCorrespondence multipleCorrespondence,
     TestablePrincipalProjections individuals,
     TestablePrincipalProjections categories
     )
 {
     this.MultipleCorrespondence = multipleCorrespondence;
     this.Individuals            = individuals;
     this.Categories             = categories;
 }
Exemple #6
0
 /// <summary>Initializes a new instance of the
 /// <see cref="TestableCorrespondence"/>
 /// class.</summary>
 /// <param name="correspondence">The correspondence to test.</param>
 /// <param name="rowProfiles">The expected row profiles.</param>
 /// <param name="columnProfiles">The expected column profiles.</param>
 public TestableCorrespondence(
     Correspondence correspondence,
     TestablePrincipalProjections rowProfiles,
     TestablePrincipalProjections columnProfiles
     )
 {
     this.Correspondence = correspondence;
     this.RowProfiles    = rowProfiles;
     this.ColumnProfiles = columnProfiles;
 }
Exemple #7
0
            /// <summary>
            /// Tests that the
            /// <see cref="PrincipalProjections.RepresentationQualities"/>
            /// property has
            /// been properly implemented.
            public static void Succeed(
                TestablePrincipalProjections testablePrincipalProjections)
            {
                var principalProjections =
                    testablePrincipalProjections.PrincipalProjections;

                DoubleMatrixAssert.AreEqual(
                    expected: testablePrincipalProjections
                    .RepresentationQualities,
                    actual: principalProjections
                    .RepresentationQualities,
                    delta: PrincipalProjectionsTest.Accuracy);
            }
Exemple #8
0
            /// <summary>
            /// Tests that the
            /// <see cref="PrincipalProjections.Variances"/>
            /// property has
            /// been properly implemented.
            public static void Succeed(
                TestablePrincipalProjections testablePrincipalProjections)
            {
                var principalProjections =
                    testablePrincipalProjections.PrincipalProjections;

                DoubleMatrixAssert.AreEqual(
                    expected: testablePrincipalProjections
                    .Variances,
                    actual: principalProjections
                    .Variances,
                    delta: PrincipalProjectionsTest.Accuracy);

                Assert.AreEqual(
                    expected: testablePrincipalProjections.Variances.Count,
                    actual: principalProjections.NumberOfDirections);
            }
Exemple #9
0
            /// <summary>
            /// Tests that the
            /// <see cref="PrincipalProjections.Contributions"/>
            /// property has
            /// been properly implemented.
            public static void Succeed(
                TestablePrincipalProjections testablePrincipalProjections)
            {
                var principalProjections =
                    testablePrincipalProjections.PrincipalProjections;

                DoubleMatrixAssert.AreEqual(
                    expected: testablePrincipalProjections
                    .Contributions,
                    actual: principalProjections
                    .Contributions,
                    delta: PrincipalProjectionsTest.Accuracy);

                Assert.AreEqual(
                    expected: Stat.Sum(testablePrincipalProjections.Contributions),
                    actual: (double)principalProjections.NumberOfDirections,
                    delta: PrincipalProjectionsTest.Accuracy);
            }
Exemple #10
0
            /// <summary>
            /// Tests that the
            /// <see cref="PrincipalProjections.RegressSupplementaryVariables"/>
            /// method succeeds when expected.
            public static void Succeed(
                TestablePrincipalProjections testablePrincipalProjections)
            {
                var principalProjections =
                    testablePrincipalProjections.PrincipalProjections;

                DoubleMatrixAssert.AreEqual(
                    expected: testablePrincipalProjections
                    .RegressionCoefficients,
                    actual: principalProjections.RegressSupplementaryVariables(
                        (DoubleMatrix)principalProjections.ActiveCloud.Coordinates),
                    delta: PrincipalProjectionsTest.Accuracy);

                DoubleMatrixAssert.AreEqual(
                    expected: testablePrincipalProjections
                    .RegressionCoefficients,
                    actual: principalProjections.RegressSupplementaryVariables(
                        principalProjections.ActiveCloud.Coordinates),
                    delta: PrincipalProjectionsTest.Accuracy);
            }
Exemple #11
0
            /// <summary>
            /// Tests that the
            /// <see cref="PrincipalProjections.LocateSupplementaryPoints"/>
            /// method succeeds when expected.
            public static void Succeed(
                TestablePrincipalProjections testablePrincipalProjections)
            {
                var principalProjections =
                    testablePrincipalProjections.PrincipalProjections;

                DoubleMatrixAssert.AreEqual(
                    expected: testablePrincipalProjections
                    .Coordinates,
                    actual: principalProjections.LocateSupplementaryPoints(
                        (DoubleMatrix)principalProjections.ActiveCloud.Coordinates),
                    delta: PrincipalProjectionsTest.Accuracy);

                DoubleMatrixAssert.AreEqual(
                    expected: testablePrincipalProjections
                    .Coordinates,
                    actual: principalProjections.LocateSupplementaryPoints(
                        principalProjections.ActiveCloud.Coordinates),
                    delta: PrincipalProjectionsTest.Accuracy);
            }