#NEWLINE# def chunk_bounds( n_samples , chunk_size , overlap = 0 ) : #NEWLINE# #INDENT# 'Return chunk bounds.\n\n    Chunks have the form:\n\n        [ overlap/2 | chunk_size-overlap | overlap/2 ]\n        s_start   keep_start           keep_end     s_end\n\n    Except for the first and last chunks which do not have a left/right\n    overlap.\n\n    This generator yields (s_start, s_end, keep_start, keep_end).\n\n    ' #NEWLINE# s_start = 0 #NEWLINE# s_end = chunk_size #NEWLINE# keep_start = s_start #NEWLINE# keep_end = ( s_end - ( overlap // 2 ) ) #NEWLINE# ( yield ( s_start , s_end , keep_start , keep_end ) ) #NEWLINE# while ( ( ( s_end - overlap ) + chunk_size ) < n_samples ) : #NEWLINE# #INDENT# s_start = ( s_end - overlap ) #NEWLINE# s_end = ( s_start + chunk_size ) #NEWLINE# keep_start = keep_end #NEWLINE# keep_end = ( s_end - ( overlap // 2 ) ) #NEWLINE# if ( s_start < s_end ) : #NEWLINE# #INDENT# ( yield ( s_start , s_end , keep_start , keep_end ) ) #NEWLINE# #UNINDENT# #UNINDENT# s_start = ( s_end - overlap ) #NEWLINE# s_end = n_samples #NEWLINE# keep_start = keep_end #NEWLINE# keep_end = s_end #NEWLINE# if ( s_start < s_end ) : #NEWLINE# #INDENT# ( yield ( s_start , s_end , keep_start , keep_end ) )