def eigenvalue_decomposition_default_epsilon_test(): pos_eigenvectors, pos_eigenvalues = eigenvalue_decomposition(cov_matrix) assert_almost_equal(pos_eigenvalues, [4.0, 2.0]) sqrt_one_over_2 = np.sqrt(2.0) / 2.0 assert_almost_equal(pos_eigenvectors, [[sqrt_one_over_2, -sqrt_one_over_2], [sqrt_one_over_2, sqrt_one_over_2]])
def test_eigenvalue_decomposition_large_epsilon(): pos_eigenvectors, pos_eigenvalues = eigenvalue_decomposition(cov_matrix, eps=0.5) assert_almost_equal(pos_eigenvalues, [4.0]) sqrt_one_over_2 = np.sqrt(2.0) / 2.0 assert_almost_equal(pos_eigenvectors, [[sqrt_one_over_2], [sqrt_one_over_2]])