#NEWLINE# def generate_slice( length , subsample ) : #NEWLINE# #INDENT# if ( subsample == 1.0 ) : #NEWLINE# #INDENT# return slice ( None , None , None ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# p = ( numpy . random . random ( ) * ( 1.0 - subsample ) ) #NEWLINE# start = int ( ( p * length ) ) #NEWLINE# stop = int ( ( ( p + subsample ) * length ) ) #NEWLINE# return slice ( start , stop , None )