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_5d
view = 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.itemsizestrides = tuple(inter_block_strides) + tuple(intra_block_strides)
// This is where the magic happens.
// Generate a view with our new strides.
return numpy.lib.stride_tricks.as_strided(a, shape=view_shape, strides=strides)