コード例 #1
0
def test_insert_directly():
    simon_algo = Simon()
    simon_algo._dict_of_linearly_indep_bit_vectors = {
        0: [1, 1, 0, 0, 0],
        1: [0, 1, 0, 1, 0]
    }
    z = np.array([0, 0, 1, 0, 1])

    simon_algo._add_to_dict_of_indep_bit_vectors(z)
    W_actual = simon_algo._dict_of_linearly_indep_bit_vectors
    W_expected = {0: [1, 1, 0, 0, 0], 1: [0, 1, 0, 1, 0], 2: [0, 0, 1, 0, 1]}

    np.testing.assert_equal(W_actual, W_expected)
コード例 #2
0
def test_no_substitution():
    simon_algo = Simon()
    simon_algo._dict_of_linearly_indep_bit_vectors = {
        0: [1, 0, 1, 0, 0],
        1: [0, 1, 0, 0, 0],
        3: [0, 0, 0, 1, 0]
    }
    z = np.array([1, 1, 1, 0,
                  0])  # linear combination of first two rows hence won't add

    simon_algo._add_to_dict_of_indep_bit_vectors(z)
    W_actual = simon_algo._dict_of_linearly_indep_bit_vectors

    W_expected = {0: [1, 0, 1, 0, 0], 1: [0, 1, 0, 0, 0], 3: [0, 0, 0, 1, 0]}

    np.testing.assert_equal(W_actual, W_expected)
コード例 #3
0
def test_simple_conflict():
    simon_algo = Simon()
    simon_algo._dict_of_linearly_indep_bit_vectors = {
        0: [1, 0, 1, 0, 0],
        1: [0, 1, 0, 0, 0],
        3: [0, 0, 0, 1, 0]
    }
    z = np.array([1, 0, 0, 0, 1])  # conflict with first row.

    simon_algo._add_to_dict_of_indep_bit_vectors(z)
    W_actual = simon_algo._dict_of_linearly_indep_bit_vectors

    W_expected = {
        0: [1, 0, 1, 0, 0],
        1: [0, 1, 0, 0, 0],
        2: [0, 0, 1, 0, 1],
        3: [0, 0, 0, 1, 0]
    }

    np.testing.assert_equal(W_actual, W_expected)