#NEWLINE# def data_chunk( data , chunk , with_overlap = False ) : #NEWLINE# #INDENT# 'Get a data chunk.' #NEWLINE# assert isinstance ( chunk , tuple ) #NEWLINE# if ( len ( chunk ) == 2 ) : #NEWLINE# #INDENT# ( i , j ) = chunk #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( len ( chunk ) == 4 ) : #NEWLINE# #INDENT# if with_overlap : #NEWLINE# #INDENT# ( i , j ) = chunk [ : 2 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ( i , j ) = chunk [ 2 : ] #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# raise ValueError ( "'chunk' should have 2 or 4 elements, not {0:d}" . format ( len ( chunk ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# return data [ i : j , ... ]