#NEWLINE# def test_inplace_column_scale( ) : #NEWLINE# #INDENT# rng = np . random . RandomState ( 0 ) #NEWLINE# X = sp . rand ( 100 , 200 , 0.05 ) #NEWLINE# Xr = X . tocsr ( ) #NEWLINE# Xc = X . tocsc ( ) #NEWLINE# XA = X . toarray ( ) #NEWLINE# scale = rng . rand ( 200 ) #NEWLINE# XA *= scale #NEWLINE# inplace_column_scale ( Xc , scale ) #NEWLINE# inplace_column_scale ( Xr , scale ) #NEWLINE# assert_array_almost_equal ( Xr . toarray ( ) , Xc . toarray ( ) ) #NEWLINE# assert_array_almost_equal ( XA , Xc . toarray ( ) ) #NEWLINE# assert_array_almost_equal ( XA , Xr . toarray ( ) ) #NEWLINE# assert_raises ( TypeError , inplace_column_scale , X . tolil ( ) , scale ) #NEWLINE# X = X . astype ( np . float32 ) #NEWLINE# scale = scale . astype ( np . float32 ) #NEWLINE# Xr = X . tocsr ( ) #NEWLINE# Xc = X . tocsc ( ) #NEWLINE# XA = X . toarray ( ) #NEWLINE# XA *= scale #NEWLINE# inplace_column_scale ( Xc , scale ) #NEWLINE# inplace_column_scale ( Xr , scale ) #NEWLINE# assert_array_almost_equal ( Xr . toarray ( ) , Xc . toarray ( ) ) #NEWLINE# assert_array_almost_equal ( XA , Xc . toarray ( ) ) #NEWLINE# assert_array_almost_equal ( XA , Xr . toarray ( ) ) #NEWLINE# assert_raises ( TypeError , inplace_column_scale , X . tolil ( ) , scale )