Beispiel #1
0
def test_pack_results_incompatible_shapes():
    def bools(*shape):
        return np.zeros(shape, dtype=bool)

    with pytest.raises(ValueError):
        cg.pack_results([('a', bools(10))])

    with pytest.raises(ValueError):
        cg.pack_results([('a', bools(7, 3)), ('b', bools(8, 2))])
Beispiel #2
0
def test_pack_results():
    measurements = [
        ('a',
         np.array([
             [0, 0, 0],
             [0, 0, 1],
             [0, 1, 0],
             [0, 1, 1],
             [1, 0, 0],
             [1, 0, 1],
             [1, 1, 0],
         ])),
        ('b', np.array([
            [0, 0],
            [0, 1],
            [1, 0],
            [1, 1],
            [0, 0],
            [0, 1],
            [1, 0],
        ])),
    ]
    data = cg.pack_results(measurements)
    expected = make_bytes("""
        000 00
        001 01
        010 10
        011 11
        100 00
        101 01
        110 10

        000 00 -- padding
    """)
    assert data == expected
Beispiel #3
0
def test_pack_results_no_measurements():
    assert cg.pack_results([]) == b''