Ejemplo n.º 1
0
    def test_validate_backprop_method_invalid_device(self):
        """Test that the method for validating the backprop diff method
        tape raises an exception if the device does not support backprop."""
        dev = qml.device("default.qubit", wires=1)

        with pytest.raises(qml.QuantumFunctionError,
                           match="does not support native computations"):
            QNode._validate_backprop_method(dev, None)
Ejemplo n.º 2
0
    def test_validate_backprop_method_invalid_interface(self, monkeypatch):
        """Test that the method for validating the backprop diff method
        tape raises an exception if the wrong interface is provided"""
        dev = qml.device("default.qubit", wires=1)
        test_interface = "something"

        monkeypatch.setitem(dev._capabilities, "passthru_interface",
                            test_interface)

        with pytest.raises(qml.QuantumFunctionError,
                           match=f"when using the {test_interface}"):
            QNode._validate_backprop_method(dev, None)
Ejemplo n.º 3
0
    def test_validate_backprop_method(self, monkeypatch):
        """Test that the method for validating the backprop diff method
        tape works as expected"""
        dev = qml.device("default.qubit", wires=1)
        test_interface = "something"
        monkeypatch.setitem(dev._capabilities, "passthru_interface",
                            test_interface)

        tape_class, interface, method = QNode._validate_backprop_method(
            dev, test_interface)

        assert tape_class is QuantumTape
        assert method == "backprop"
        assert interface == None