예제 #1
0
    def test_apply_parametrized_operation_inverse(self, op, pars, wires, expected_circuit):
        """Tests that inverse operations get recognized and converted to correct parameters for
        parametrized ops."""

        dev = AQTDevice(2, api_key=SOME_API_KEY)
        dev._apply_operation(op(*pars, wires=wires).inv())

        assert dev.circuit == expected_circuit
예제 #2
0
    def test_apply_operation_R(self, wires, par0, par1):
        """Tests that the _apply_operation method correctly populates the circuit
        queue when a R gate operation is provided."""

        dev = AQTDevice(3, api_key=SOME_API_KEY)
        assert dev.circuit == []

        dev._apply_operation(ops.R(par0, par1, wires=wires))

        assert dev.circuit == [["R", par0, par1, wires]]
예제 #3
0
    def test_apply_operation_pauli(self, wires, op, aqt_name):
        """Tests that the _apply_operation method correctly populates the circuit
        queue when a PennyLane Pauli operation is provided."""

        dev = AQTDevice(3, api_key=SOME_API_KEY)
        assert dev.circuit == []

        dev._apply_operation(op(wires=wires))

        assert dev.circuit == [[aqt_name, 1.0, wires]]
예제 #4
0
    def test_apply_operation_S(self, wires):
        """Tests that the _apply_operation method correctly populates the circuit
        queue when a PennyLane S operation is provided."""

        dev = AQTDevice(3, api_key=SOME_API_KEY)
        assert dev.circuit == []

        dev._apply_operation(qml.S(wires=wires))

        assert dev.circuit == [["Z", 0.5, wires]]
예제 #5
0
    def test_apply_operation_hadamard(self, wires):
        """Tests that the _apply_operation method correctly populates the circuit
        queue when a PennyLane Hadamard operation is provided."""

        dev = AQTDevice(3, api_key=SOME_API_KEY)
        assert dev.circuit == []

        dev._apply_operation(qml.Hadamard(wires=wires))

        assert dev.circuit == [["X", 1.0, wires], ["Y", -0.5, wires]]
예제 #6
0
    def test_apply_operation_rotations(self, op, par, wires, aqt_name):
        """Tests that the _apply_operation method correctly populates the circuit
        queue when a PennyLane RX, RY, or RZ operation is provided."""

        dev = AQTDevice(3, api_key=SOME_API_KEY)
        assert dev.circuit == []

        dev._apply_operation(op(par, wires=wires))
        aqt_par = par / np.pi

        assert dev.circuit == [[aqt_name, aqt_par, wires]]
예제 #7
0
    def test_apply_operation_basisstate(self, wires, state):
        """Tests that the _apply_operation method correctly populates the circuit
        queue when a PennyLane BasisState operation is provided."""

        dev = AQTDevice(3, api_key=SOME_API_KEY)
        assert dev.circuit == []

        dev._apply_operation(qml.BasisState(np.array(state), wires=wires))
        expected_circuit = []
        for bit, wire in zip(state, wires):
            if bit == 1:
                expected_circuit.append(["X", 1.0, [wire]])

        assert dev.circuit == expected_circuit