def test_format_matrix_dim_dim_blocksize(blocksize):
    # Testing if input matrix is in perfect format (dim,dim,blocksize)
    dim = 3
    input_matrix = np.random.randn(dim, dim, blocksize)
    test_matrix = format_matrix_shape(input_matrix)

    # No need to reshape the input matrix
    assert_allclose(test_matrix, input_matrix)
def test_format_matrix_blocksize_dim_dim(blocksize):
    # Testing if elements of input matrix is (blocksize,dim,dim)
    # and taking transpose of the matrix. note that blocksize>dim=3
    dim = 3
    input_matrix = np.random.randn(blocksize, dim, dim)
    test_matrix = format_matrix_shape(input_matrix)

    # Reshape the input matrix
    correct_matrix = input_matrix.T
    assert_allclose(test_matrix, correct_matrix)
def test_format_matrix_dim_power_2_blocksize(blocksize):
    # Testing if elements of input matrix is column vector of dim**2
    # Change block sizes using parametric testing ##
    dim = 3
    input_matrix = np.random.randn(dim ** 2, blocksize)
    test_matrix = format_matrix_shape(input_matrix)

    # Reshape the input matrix
    correct_matrix = input_matrix.reshape(dim, dim, blocksize)
    assert_allclose(test_matrix, correct_matrix)
def test_format_matrix_dim_dim():
    # Testing if elements of input matrix is (dim,dim) and converting it to
    # (dim,dim,1) and expanding dimension.
    # Change block sizes using parametric testing ##
    dim = 3
    blocksize = 1
    input_matrix = np.random.randn(dim, dim)
    test_matrix = format_matrix_shape(input_matrix)

    # Reshape the input matrix
    correct_matrix = input_matrix.reshape(dim, dim, blocksize)
    assert_allclose(test_matrix, correct_matrix)
def test_format_matrix_shape_1D():
    # Testing if input array is 1D, and its shape is dim**2
    # This is the only possibility for 1D array otherwise, it
    # cannot be square matrix.
    dim = 3
    blocksize = 1
    input_matrix = np.random.randn(dim ** 2)
    test_matrix = format_matrix_shape(input_matrix)

    # Reshape the input matrix
    correct_matrix = input_matrix.reshape(dim, dim, blocksize)
    assert_allclose(test_matrix, correct_matrix)