def slice_array(out_name, in_name, blockdims, index):
 index = replace_ellipsis(len(blockdims), index)
 index = tuple(map(sanitize_index, index))
 blockdims = tuple(map(tuple, blockdims))
 if all(((index == slice(None, None, None)) for index in index)):
  suffixes = product(*[range(len(bd)) for bd in blockdims])
  dsk = dict(((((out_name,) + s), ((in_name,) + s)) for s in suffixes))
  return (dsk, blockdims)
 missing = (len(blockdims) - (len(index) - index.count(None)))
 index += ((slice(None, None, None),) * missing)
 (dsk_out, bd_out) = slice_with_newaxes(out_name, in_name, blockdims, index)
 bd_out = tuple(map(tuple, bd_out))
 return (dsk_out, bd_out)

def slice_array ( out_name , in_name , blockdims , index ) : index = replace_ellipsis ( len ( blockdims ) , index ) index = tuple ( map ( sanitize_index , index ) ) blockdims = tuple ( map ( tuple , blockdims ) ) if all ( ( ( index == slice ( None , None , None ) ) for index in index ) ) : suffixes = product ( * [ range ( len ( bd ) ) for bd in blockdims ] ) dsk = dict ( ( ( ( ( out_name , ) + s ) , ( ( in_name , ) + s ) ) for s in suffixes ) ) return ( dsk , blockdims ) missing = ( len ( blockdims ) - ( len ( index ) - index . count ( None ) ) ) index += ( ( slice ( None , None , None ) , ) * missing ) ( dsk_out , bd_out ) = slice_with_newaxes ( out_name , in_name , blockdims , index ) bd_out = tuple ( map ( tuple , bd_out ) ) return ( dsk_out , bd_out )
master function for array slicing this function makes a new dask that slices blocks along every dimension and aggregates each dimensions slices so that the resulting block slices give the same results as the original slice on the original structure index must be a tuple .