Skip to content

Commit 17d9912

Browse files
committed
fix DeviceError errors
1 parent 33ef66e commit 17d9912

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

tests/lightning_tensor/test_tensornet_class.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import pennylane as qml
2222
import pytest
2323
from conftest import LightningDevice, device_name # tested device
24-
from pennylane import DeviceError
2524
from pennylane.wires import Wires
2625

2726
if device_name != "lightning.tensor":
@@ -88,6 +87,7 @@ def test_errors_apply_operation_state_preparation(operation, par):
8887
tensornet = LightningTensorNet(wires, bondDims)
8988

9089
with pytest.raises(
91-
DeviceError, match="lightning.tensor does not support initialization with a state vector."
90+
qml.DeviceError,
91+
match="lightning.tensor does not support initialization with a state vector.",
9292
):
9393
tensornet.apply_operations([operation(np.array(par), Wires(range(wires)))])

tests/test_measurements.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ def circuit():
393393
qml.RX(0.52, wires=0)
394394
return qml.expval(qml.RX(0.742, wires=[0]))
395395

396-
with pytest.raises(qml._device.DeviceError, match="Observable RX.*not supported"):
396+
with pytest.raises(qml.DeviceError, match="Observable RX.*not supported"):
397397
circuit()
398398

399399
def test_observable_return_type_is_expectation(self, dev):
@@ -494,7 +494,7 @@ def circuit():
494494
qml.RX(0.52, wires=0)
495495
return qml.var(qml.RX(0.742, wires=[0]))
496496

497-
with pytest.raises(qml._device.DeviceError, match="Observable RX.*not supported"):
497+
with pytest.raises(qml.DeviceError, match="Observable RX.*not supported"):
498498
circuit()
499499

500500
def test_observable_return_type_is_variance(self, dev):
@@ -523,7 +523,7 @@ def circuit():
523523
qml.RX(0.52, wires=0)
524524
return qml.var(qml.RX(0.742, wires=[0]))
525525

526-
with pytest.raises(qml._device.DeviceError, match="Observable RX.*not supported"):
526+
with pytest.raises(qml.DeviceError, match="Observable RX.*not supported"):
527527
circuit()
528528

529529

tests/test_native_mcm.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import pytest
2121
from conftest import LightningDevice, device_name, validate_measurements
2222
from flaky import flaky
23-
from pennylane._device import DeviceError
2423

2524
if device_name not in ("lightning.qubit", "lightning.kokkos"):
2625
pytest.skip("Native MCM not supported. Skipping.", allow_module_level=True)
@@ -86,7 +85,7 @@ def func(x, y):
8685

8786
if device_name == "lightning.qubit":
8887
with pytest.raises(
89-
DeviceError,
88+
qml.DeviceError,
9089
match=f"not accepted with finite shots on lightning.qubit",
9190
):
9291
func(*params)

tests/test_templates.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def circuit(feature_vector):
176176

177177
X = np.arange(1, n_qubits + 1)
178178

179-
with pytest.raises(qml._device.DeviceError, match="not supported"):
179+
with pytest.raises(qml.DeviceError, match="not supported"):
180180
_ = qml.QNode(circuit, dev, diff_method=None)(X)
181181

182182

@@ -242,7 +242,7 @@ def circuit(weights):
242242
shapes = qml.CVNeuralNetLayers.shape(n_layers=2, n_wires=n_qubits)
243243
weights = [np.random.random(shape) for shape in shapes]
244244

245-
with pytest.raises(qml._device.DeviceError, match="not supported"):
245+
with pytest.raises(qml.DeviceError, match="not supported"):
246246
_ = qml.QNode(circuit, dev, diff_method=None)(weights)
247247

248248

0 commit comments

Comments
 (0)