def permuteToBlocks(arr, blockshape):
 if (len(blockshape) < 2):
  raise ValueError('Need more than one dimension.')
 elif (len(blockshape) == 2):
  (blockheight, blockwidth) = blockshape
  return permuteToBlocks2d(arr, blockheight, blockwidth)
 elif (len(blockshape) == 3):
  (blockdepth, blockheight, blockwidth) = blockshape
  return permuteToBlocks3d(arr, blockdepth, blockheight, blockwidth)
 else:
  raise NotImplementedError('Only for dimensions 2 and 3.')

def permuteToBlocks ( arr , blockshape ) : if ( len ( blockshape ) < 2 ) : raise ValueError ( 'Need more than one dimension.' ) elif ( len ( blockshape ) == 2 ) : ( blockheight , blockwidth ) = blockshape return permuteToBlocks2d ( arr , blockheight , blockwidth ) elif ( len ( blockshape ) == 3 ) : ( blockdepth , blockheight , blockwidth ) = blockshape return permuteToBlocks3d ( arr , blockdepth , blockheight , blockwidth ) else : raise NotImplementedError ( 'Only for dimensions 2 and 3.' )
permute an array so that it consists of linearized blocks .