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()); }
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); }
public void StandardizeTest() { CloudTest.Standardize.Succeed( TestableCloud00.Get()); }
public void CentredTest() { CloudTest.Center.Succeed( TestableCloud00.Get()); }
public void CovarianceTest() { CloudTest.Covariance.Succeed( TestableCloud00.Get()); }
public void MeanTest() { CloudTest.Mean.Succeed( TestableCloud00.Get()); }
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); } }
public void BasisTest() { CloudTest.Basis.Succeed( TestableCloud00.Get()); }
public void WeightsTest() { CloudTest.Weights.Succeed( TestableCloud00.Get()); }
public void CoordinatesTest() { CloudTest.Coordinates.Succeed( TestableCloud00.Get()); }