Exemplo n.º 1
0
def test_default_ancilla_assignment():
    """
    Make sure ancilla is assigned to max(regA + regB) + 1 by default
    :return:
    """
    test_prog_for_ancilla = swap_circuit_generator([1, 2], [5, 6], None)
    instruction = test_prog_for_ancilla.pop()
    assert instruction.qubits[0].index == 7
Exemplo n.º 2
0
def test_cswap_program():
    """
    Test if the correct program is returned.  Half way to system test
    """
    test_prog = swap_circuit_generator([1, 2], [5, 6], None)
    true_prog = Program()
    true_prog += H(7)
    true_prog += CSWAP(7, 1, 5)
    true_prog += CSWAP(7, 2, 6)
    true_prog += H(7)

    assert test_prog.out() == true_prog.out()
Exemplo n.º 3
0
def test_swap_circuit_gen_type():
    """
    Test the type checking
    """
    with pytest.raises(TypeError):
        swap_circuit_generator(5, [1, 2], 0)

    with pytest.raises(TypeError):
        swap_circuit_generator([1, 2], 5, 0)

    with pytest.raises(RegisterSizeMismatch):
        swap_circuit_generator([1, 2], [3], 0)