<s> import sys <EOL> import numpy as np <EOL> def chunks ( l , n ) : <EOL> """<STR_LIT>""" <EOL> for i in xrange ( <NUM_LIT:0> , len ( l ) , n ) : <EOL> yield l [ i : i + n ] <EOL> class ChunkedTransform ( object ) : <EOL> verbose = <NUM_LIT:0> <EOL> def transform ( self , X ) : <EOL> features = None <EOL> for chunk in chunks ( X , self . batch_size ) : <EOL> if features is not None : <EOL> features = np . vstack ( <EOL> [ features , self . _compute_features ( chunk ) ] ) <EOL> else : <EOL> features = self . _compute_features ( chunk ) <EOL> if self . verbose : <EOL> sys . stdout . write ( <EOL> "<STR_LIT>" % ( <EOL> self . __class__ . __name__ , <EOL> <NUM_LIT> * len ( features ) / len ( X ) , <EOL> ) ) <EOL> sys . stdout . flush ( ) <EOL> if self . verbose : <EOL> sys . stdout . write ( '<STR_LIT:\n>' ) <EOL> return features </s>
