def test_parameter_shift_tape_unknown_model(self, monkeypatch): """test that an unknown model raises an exception""" def capabilities(cls): capabilities = cls._capabilities capabilities.update(model="None") return capabilities monkeypatch.setattr(qml.devices.DefaultQubit, "capabilities", capabilities) dev = qml.device("default.qubit", wires=1) with pytest.raises(qml.QuantumFunctionError, match="does not support the parameter-shift rule"): QNode._get_parameter_shift_tape(dev)
def test_parameter_shift_tape_qubit_device(self): """Test that the get_parameter_shift_method method correctly and returns the correct tape for qubit devices.""" dev = qml.device("default.qubit", wires=1) tape_class = QNode._get_parameter_shift_tape(dev) assert tape_class is QubitParamShiftTape