(B)
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
Reblock a BlockMatrix so that it has 2x2 blocks of block matrices
Reblock a BlockMatrix so that it has 2x2 blocks of block matrices
def reblock_2x2(B):
    """ Reblock a BlockMatrix so that it has 2x2 blocks of block matrices """
    if not isinstance(B, BlockMatrix) or not all(d > 2 for d in B.blocks.shape):
        return B

    BM = BlockMatrix  # for brevity's sake
    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 # for brevity's sake return BM ( [ [ B . blocks [ 0 , 0 ] , BM ( B . blocks [ 0 , 1 : ] ) ] , [ BM ( B . blocks [ 1 : , 0 ] ) , BM ( B . blocks [ 1 : , 1 : ] ) ] ] )