#NEWLINE# def test_row_norms( ) : #NEWLINE# #INDENT# X = np . random . RandomState ( 42 ) . randn ( 100 , 100 ) #NEWLINE# sq_norm = ( X ** 2 ) . sum ( axis = 1 ) #NEWLINE# assert_array_almost_equal ( sq_norm , row_norms ( X , squared = True ) , 5 ) #NEWLINE# assert_array_almost_equal ( np . sqrt ( sq_norm ) , row_norms ( X ) ) #NEWLINE# Xcsr = sparse . csr_matrix ( X , dtype = np . float32 ) #NEWLINE# assert_array_almost_equal ( sq_norm , row_norms ( Xcsr , squared = True ) , 5 ) #NEWLINE# assert_array_almost_equal ( np . sqrt ( sq_norm ) , row_norms ( Xcsr ) )