#NEWLINE# def get_excerpts( data , n_excerpts = None , excerpt_size = None ) : #NEWLINE# #INDENT# assert ( n_excerpts is not None ) #NEWLINE# assert ( excerpt_size is not None ) #NEWLINE# if ( len ( data ) < ( n_excerpts * excerpt_size ) ) : #NEWLINE# #INDENT# return data #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( n_excerpts == 0 ) : #NEWLINE# #INDENT# return data [ : 0 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( n_excerpts == 1 ) : #NEWLINE# #INDENT# return excerpt_size [ : excerpt_size ] #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# out = np . concatenate ( [ data_chunk ( data , chunk ) for chunk in excerpts ( len ( data ) , n_excerpts = n_excerpts , excerpt_size = excerpt_size ) ] ) #NEWLINE# assert ( len ( out ) <= ( n_excerpts * excerpt_size ) ) #NEWLINE# return out