#NEWLINE# def test_cov_nearest_factor_homog_sparse( self ) : #NEWLINE# #INDENT# d = 100 #NEWLINE# for dm in ( 1 , 2 ) : #NEWLINE# #INDENT# X = np . zeros ( ( d , dm ) , dtype = np . float64 ) #NEWLINE# x = np . linspace ( 0 , ( 2 * np . pi ) , d ) #NEWLINE# for j in range ( dm ) : #NEWLINE# #INDENT# X [ : , j ] = np . sin ( ( x * ( j + 1 ) ) ) #NEWLINE# #UNINDENT# mat = np . dot ( X , rslt . T ) #NEWLINE# np . fill_diagonal ( mat , ( np . diag ( mat ) + 3.1 ) ) #NEWLINE# rslt = cov_nearest_factor_homog ( mat , dm ) #NEWLINE# mat1 = rslt . to_matrix ( ) #NEWLINE# smat = sparse . csr_matrix ( mat ) #NEWLINE# rslt = cov_nearest_factor_homog ( smat , dm ) #NEWLINE# mat2 = rslt . to_matrix ( ) #NEWLINE# assert_allclose ( mat1 , mat2 , rtol = 0.25 , atol = 0.001 )