#NEWLINE# def test_make_sparse_coded_signal( ) : #NEWLINE# #INDENT# ( Y , D , X ) = make_sparse_coded_signal ( n_samples = 5 , n_components = 8 , n_features = 10 , n_nonzero_coefs = 3 , random_state = 0 ) #NEWLINE# assert_equal ( Y . shape , ( 10 , 5 ) , 'Y shape mismatch' ) #NEWLINE# assert_equal ( D . shape , ( 10 , 8 ) , 'D shape mismatch' ) #NEWLINE# assert_equal ( X . shape , ( 8 , 5 ) , 'X shape mismatch' ) #NEWLINE# for col in X . T : #NEWLINE# #INDENT# assert_equal ( len ( np . flatnonzero ( col ) ) , 3 , 'Non-zero coefs mismatch' ) #NEWLINE# #UNINDENT# assert_array_almost_equal ( np . dot ( D , X ) , Y ) #NEWLINE# assert_array_almost_equal ( np . sqrt ( ( D ** 2 ) . sum ( axis = 0 ) ) , np . ones ( D . shape [ 1 ] ) )