示例#1
0
    def test_qasm_(self, recorder):
        """Tests that a QuantumCircuit object is deserialized from a qasm string."""
        qasm_string = (
            'include "qelib1.inc";'
            "qreg q[4];"
            "creg c[4];"
            "x q[0];"
            "cx q[2],q[0];"
            "measure q -> c;"
        )

        quantum_circuit = load_qasm(qasm_string)

        with pytest.warns(UserWarning) as record:
            with recorder:
                quantum_circuit(params={})

        assert len(recorder.queue) == 2

        assert recorder.queue[0].name == "PauliX"
        assert recorder.queue[0].parameters == []
        assert recorder.queue[0].wires == Wires([0])

        assert recorder.queue[1].name == "CNOT"
        assert recorder.queue[1].parameters == []
        assert recorder.queue[1].wires == Wires([2, 0])
    def test_qasm_(self, recorder):
        """Tests that a QuantumCircuit object is deserialized from a qasm string."""
        qasm_string = 'include "qelib1.inc";' \
                      'qreg q[4];' \
                      'creg c[4];' \
                      'x q[0];' \
                      'cx q[2],q[0];'\
                      'measure q -> c;'

        quantum_circuit = load_qasm(qasm_string)

        with pytest.warns(UserWarning) as record:
            with recorder:
                quantum_circuit(params={})

        assert len(recorder.queue) == 2

        assert recorder.queue[0].name == 'PauliX'
        assert recorder.queue[0].params == []
        assert recorder.queue[0].wires == [0]

        assert recorder.queue[1].name == 'CNOT'
        assert recorder.queue[1].params == []
        assert recorder.queue[1].wires == [2, 0]