Decode data using Hamming(7, 4) code.

    E.g.:
        decode([1, 0, 0, 0, 0, 1, 1])

        encode([[1, 1, 0, 1, 0, 0, 1],
                [0, 1, 0, 0, 1, 0, 1]])

    :param array C: binary data to code (must be shaped as (7, ) or (-1, 7)).

def decode(C):
    """ Decode data using Hamming(7, 4) code.

    E.g.:
        decode([1, 0, 0, 0, 0, 1, 1])

        encode([[1, 1, 0, 1, 0, 0, 1],
                [0, 1, 0, 0, 1, 0, 1]])

    :param array C: binary data to code (must be shaped as (7, ) or (-1, 7)).

    """
    C = array(C)

    flatten = False
    if len(C.shape) == 1:
        flatten = True
        C = C.reshape(1, -1)

    if C.shape[1] != msg_size:
        raise ValueError('Data must be shaped as (7, ) or (-1, 7)')

    if 1 in dot(H, C.T).T % 2:
        raise ValueError('Incorrect code given as input.')

    B = C[:, data_bits]

    if flatten:
        B = B.flatten()

    return B