#NEWLINE# def iter_data( * data , **kwargs ) : #NEWLINE# #INDENT# size = kwargs . get ( 'size' , 128 ) #NEWLINE# try : #NEWLINE# #INDENT# n = len ( data [ 0 ] ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# n = data [ 0 ] . shape [ 0 ] #NEWLINE# #UNINDENT# batches = ( n / size ) #NEWLINE# if ( ( n % size ) != 0 ) : #NEWLINE# #INDENT# batches += 1 #NEWLINE# #UNINDENT# for b in range ( batches ) : #NEWLINE# #INDENT# start = ( b * size ) #NEWLINE# end = ( ( b + 1 ) * size ) #NEWLINE# if ( end > n ) : #NEWLINE# #INDENT# end = n #NEWLINE# #UNINDENT# if ( len ( data ) == 1 ) : #NEWLINE# #INDENT# ( yield data [ 0 ] [ start : end ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ( yield tuple ( [ d [ start : end ] for d in data ] ) )