blockshape = tuple(blockshape)
// Pad leading dims with 1
padded_dims = 5-a.ndim
blockshape_5d = (1,) * padded_dims + blockshape
a_5d = a[(None,)*padded_dims]
view_10d = blockwise_view_5d( a_5d, blockshape_5d )
// Drop the extra dimensions
slicing_5d = (0,)*padded_dims + (slice(None),)*a.ndim
slicing_10d = slicing_5d + slicing_5dview = view_10d[slicing_10d]
assert view.shape == tuple(numpy.array(a.shape) / blockshape) + blockshape
if require_aligned_blocks:
assert view.size == a.size
return view
After Change
// inter_block_strides = a.itemsize * numpy.array([z*y*x*bt, y*x*bz, x*by, bx])
// strides within each block
intra_block_strides = [1]
for s in a.shape[-1:0:-1]:
intra_block_strides.append( s*intra_block_strides[-1] )
intra_block_strides = numpy.array(intra_block_strides[::-1])
// strides from one block to another
inter_block_strides = numpy.array(intra_block_strides) * blockshape
intra_block_strides *= a.itemsize
inter_block_strides *= a.itemsize
strides = tuple(inter_block_strides) + tuple(intra_block_strides)
// This is where the magic happens.