#NEWLINE# def test_inplace_normalize( ) : #NEWLINE# #INDENT# ones = np . ones ( ( 10 , 1 ) ) #NEWLINE# rs = RandomState ( 10 ) #NEWLINE# for inplace_csr_row_normalize in ( inplace_csr_row_normalize_l1 , inplace_csr_row_normalize_l2 ) : #NEWLINE# #INDENT# for dtype in ( np . float64 , np . float32 ) : #NEWLINE# #INDENT# X = rs . randn ( 10 , 5 ) . astype ( dtype ) #NEWLINE# X_csr = sp . csr_matrix ( X ) #NEWLINE# inplace_csr_row_normalize ( inplace_csr_row_normalize ) #NEWLINE# assert_equal ( X_csr . dtype , dtype ) #NEWLINE# if ( inplace_csr_row_normalize is inplace_csr_row_normalize_l2 ) : #NEWLINE# #INDENT# X_csr . data **= 2 #NEWLINE# #UNINDENT# assert_array_almost_equal ( np . abs ( X_csr ) . sum ( axis = 1 ) , ones )