#NEWLINE# def _chunk_data( X , slices ) : #NEWLINE# #INDENT# 'Smart chunking to avoid memory overload.\n\n    The parallelization is performed across time samples. To avoid overheads,\n    the X data is splitted into large chunks of different time sizes. To\n    avoid duplicating the memory load to each job, we only pass the time\n    samples that are required by each job. The indices of the training times\n    must be adjusted accordingly.\n    ' #NEWLINE# slices = [ sl for sl in slices if len ( sl ) ] #NEWLINE# selected_times = np . hstack ( [ np . ravel ( sl ) for sl in slices ] ) #NEWLINE# start = np . min ( selected_times ) #NEWLINE# stop = ( np . max ( selected_times ) + 1 ) #NEWLINE# slices_chunk = [ ( sl - start ) for sl in slices ] #NEWLINE# X_chunk = X [ : , : , start : stop ] #NEWLINE# return ( X_chunk , slices_chunk )