Skip to content

Commit 967032e

Browse files
committed
use exceptions
1 parent 4369020 commit 967032e

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

pennylane_aqt/device.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from time import sleep
2424

2525
import numpy as np
26-
from pennylane import DeviceError
26+
from pennylane.exceptions import DeviceError
2727
from pennylane.devices import QubitDevice
2828
from pennylane.ops import Adjoint
2929

tests/test_device.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def test_retry_delay(self):
110110
dev.retry_delay = 1.0
111111
assert dev.retry_delay == 1.0
112112

113-
with pytest.raises(qml.DeviceError, match="needs to be positive"):
113+
with pytest.raises(qml.exceptions.DeviceError, match="needs to be positive"):
114114
dev.retry_delay = -5
115115

116116
def test_set_api_configs(self):
@@ -304,7 +304,9 @@ def test_apply_basisstate_not_first_exception(self):
304304

305305
dev = AQTDevice(3, api_key=SOME_API_KEY)
306306

307-
with pytest.raises(qml.DeviceError, match="only supported at the beginning of a circuit"):
307+
with pytest.raises(
308+
qml.exceptions.DeviceError, match="only supported at the beginning of a circuit"
309+
):
308310
dev.apply([qml.RX(0.5, wires=1), qml.BasisState(np.array([1, 1, 1]), wires=[0, 1, 2])])
309311

310312
def test_apply_statevector_not_first_exception(self):
@@ -314,7 +316,9 @@ def test_apply_statevector_not_first_exception(self):
314316
dev = AQTDevice(2, api_key=SOME_API_KEY)
315317

316318
state = np.ones(8) / np.sqrt(8)
317-
with pytest.raises(qml.DeviceError, match="only supported at the beginning of a circuit"):
319+
with pytest.raises(
320+
qml.exceptions.DeviceError, match="only supported at the beginning of a circuit"
321+
):
318322
dev.apply([qml.RX(0.5, wires=1), qml.StatePrep(state, wires=[0, 1, 2])])
319323

320324
def test_apply_raises_for_error(self, monkeypatch):
@@ -409,7 +413,7 @@ def test_unsupported_operation_exception(self):
409413

410414
dev = AQTDevice(1, api_key=SOME_API_KEY)
411415

412-
with pytest.raises(qml.DeviceError, match="is not supported on AQT devices"):
416+
with pytest.raises(qml.exceptions.DeviceError, match="is not supported on AQT devices"):
413417
dev._append_op_to_queue("BAD_GATE", 0.5, [0])
414418

415419

0 commit comments

Comments
 (0)