def reblock_2x2(B):
 if ((not isinstance(B, BlockMatrix)) or (not all(((d > 2) for d in B.blocks.shape)))):
  return B
 BM = BlockMatrix
 return BM([[B.blocks[(0, 0)], BM(B.blocks[0, 1:])], [BM(B.blocks[1:, 0]), BM(B.blocks[1:, 1:])]])

def reblock_2x2 ( B ) : if ( ( not isinstance ( B , BlockMatrix ) ) or ( not all ( ( ( d > 2 ) for d in B . blocks . shape ) ) ) ) : return B BM = BlockMatrix return BM ( [ [ B . blocks [ ( 0 , 0 ) ] , BM ( B . blocks [ 0 , 1 : ] ) ] , [ BM ( B . blocks [ 1 : , 0 ] ) , BM ( B . blocks [ 1 : , 1 : ] ) ] ] )
reblock a blockmatrix so that it has 2x2 blocks of block matrices .