From 3cda097af35575ce1f1e9783506e5e9a19d8a9a8 Mon Sep 17 00:00:00 2001 From: Astral Cai Date: Mon, 16 Sep 2024 16:13:33 -0400 Subject: [PATCH 1/2] Fix deprecated import path for `QubitDevice` --- pennylane_qulacs/qulacs_device.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pennylane_qulacs/qulacs_device.py b/pennylane_qulacs/qulacs_device.py index e8b9031..75c9772 100644 --- a/pennylane_qulacs/qulacs_device.py +++ b/pennylane_qulacs/qulacs_device.py @@ -20,7 +20,8 @@ import numpy as np -from pennylane import QubitDevice, DeviceError +from pennylane.devices import QubitDevice +from pennylane import DeviceError from pennylane.ops import ( QubitStateVector, BasisState, From fb597c7d3cb30c10863728dfc70d6b0d75f2aea8 Mon Sep 17 00:00:00 2001 From: Astral Cai Date: Thu, 19 Sep 2024 09:55:24 -0400 Subject: [PATCH 2/2] Remove tests of deprecated `QubitStateVector` --- tests/test_apply.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/tests/test_apply.py b/tests/test_apply.py index e8debff..688de1a 100755 --- a/tests/test_apply.py +++ b/tests/test_apply.py @@ -163,13 +163,12 @@ def test_basis_state_on_wires_subset(self, state, device_wires, op_wires, tol): expected = dev._expand_state(expected, op_wires) assert np.allclose(res, expected, tol) - @pytest.mark.parametrize("state_prep_op", (qml.QubitStateVector, qml.StatePrep)) - def test_qubit_state_vector(self, init_state, state_prep_op, tol): - """Test QubitStateVector and StatePrep application""" + def test_qubit_state_vector(self, init_state, tol): + """Test StatePrep application""" dev = QulacsDevice(1) state = init_state(1) - op = state_prep_op(state, wires=[0]) + op = qml.StatePrep(state, wires=[0]) dev.apply([op]) dev._obs_queue = [] @@ -177,17 +176,14 @@ def test_qubit_state_vector(self, init_state, state_prep_op, tol): expected = state assert np.allclose(res, expected, tol) - @pytest.mark.parametrize("state_prep_op", (qml.QubitStateVector, qml.StatePrep)) @pytest.mark.parametrize("device_wires", [3, 4, 5]) @pytest.mark.parametrize("op_wires", [[0], [2], [0, 1], [1, 0], [2, 0]]) - def test_qubit_state_vector_on_wires_subset( - self, init_state, device_wires, op_wires, state_prep_op, tol - ): - """Test QubitStateVector and StatePrep application on a subset of device wires""" + def test_qubit_state_vector_on_wires_subset(self, init_state, device_wires, op_wires, tol): + """Test StatePrep application on a subset of device wires""" dev = QulacsDevice(device_wires) state = init_state(len(op_wires)) - op = state_prep_op(state, wires=op_wires) + op = qml.StatePrep(state, wires=op_wires) dev.apply([op]) dev._obs_queue = []