2626 DEALINGS IN THE SOFTWARE.
2727 */
2828
29+ // ComputePCA module test.
2930#include < Testing/ModuleTestBase/ModuleTestBase.h>
3031#include < Modules/Math/ComputePCA.h>
3132#include < Core/Datatypes/DenseColumnMatrix.h>
@@ -43,6 +44,7 @@ class ComputePCAtest : public ModuleTest
4344{
4445};
4546
47+ // Checks for null input.
4648TEST_F (ComputePCAtest, CheckInputNull)
4749{
4850 auto pcaMod = makeModule (" ComputePCA" );
@@ -52,25 +54,30 @@ TEST_F(ComputePCAtest, CheckInputNull)
5254 EXPECT_THROW (pcaMod -> execute (), NullHandleOnPortException);
5355}
5456
55- TEST_F (ComputePCAtest, CheckInputColumn)
57+ // Checks for dense input.
58+ TEST_F (ComputePCAtest, CheckInputDense)
5659{
5760 auto pcaMod = makeModule (" ComputePCA" );
58- DenseColumnMatrixHandle columnInput (new DenseColumnMatrix (5 ));
59- (*columnInput) << 1 ,2 ,3 ,4 ,5 ;
60- stubPortNWithThisData (pcaMod, 0 , columnInput);
61+ MatrixHandle denseMatrix = MAKE_DENSE_MATRIX_HANDLE ((1 ,2 ,5 ,6 )(3 ,4 ,7 ,9 )(7 ,8 ,9 ,1 )(2 ,3 ,5 ,9 ));
62+ stubPortNWithThisData (pcaMod, 0 , denseMatrix);
6163
6264 EXPECT_NO_THROW (pcaMod -> execute ());
6365}
6466
65- TEST_F (ComputePCAtest, CheckInputDense)
67+ // ComputePCA currently only supports dense input, but we will leave these if we want to change it later.
68+ // There is a check for this in the algorithm.
69+ // Checks for column input.
70+ TEST_F (ComputePCAtest, CheckInputColumn)
6671{
6772 auto pcaMod = makeModule (" ComputePCA" );
68- MatrixHandle denseMatrix = MAKE_DENSE_MATRIX_HANDLE ((1 ,2 ,5 ,6 )(3 ,4 ,7 ,9 )(7 ,8 ,9 ,1 )(2 ,3 ,5 ,9 ));
69- stubPortNWithThisData (pcaMod, 0 , denseMatrix);
73+ DenseColumnMatrixHandle columnInput (new DenseColumnMatrix (5 ));
74+ (*columnInput) << 1 ,2 ,3 ,4 ,5 ;
75+ stubPortNWithThisData (pcaMod, 0 , columnInput);
7076
7177 EXPECT_NO_THROW (pcaMod -> execute ());
7278}
7379
80+ // Checks for sparse input.
7481TEST_F (ComputePCAtest, CheckInputSparse)
7582{
7683 auto pcaMod = makeModule (" ComputePCA" );
0 commit comments