#NEWLINE# def handle( self , vals ) : #NEWLINE# #INDENT# if self . sample_before_thresholding : #NEWLINE# #INDENT# ( train , test ) = self . split ( vals ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ( train , test ) = self . stratified_split ( vals ) #NEWLINE# #UNINDENT# train = [ ( v , c ) for ( v , c ) in train if ( ( not self . discard_zeros ) or ( c > 0 ) ) ] #NEWLINE# test = [ ( v , c ) for ( v , c ) in test if ( c > 0 ) ] #NEWLINE# if self . normalize : #NEWLINE# #INDENT# norm = ( sum ( ( ( c * c ) for ( v , c ) in train ) ) ** 0.5 ) #NEWLINE# if ( norm > 0 ) : #NEWLINE# #INDENT# train = [ ( v , ( c / norm ) ) for ( v , c ) in train ] #NEWLINE# #UNINDENT# #UNINDENT# return ( train , c )