From 3718dd66b15561faa97166a2cbf16394ead9d7f5 Mon Sep 17 00:00:00 2001 From: Mudit Pandey Date: Tue, 17 Sep 2024 17:32:48 -0400 Subject: [PATCH] Test changes to account for 0.39 deprecations (#912) Updating some tests to account for various deprecations happening in pennylane for v0.39. --------- Co-authored-by: ringo-but-quantum --- .github/CHANGELOG.md | 5 ++++- mpitests/test_adjoint_jacobian.py | 6 +++--- pennylane_lightning/core/_version.py | 2 +- tests/test_adjoint_jacobian.py | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index 0262afc467..ce2d763cf0 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -31,6 +31,9 @@ ### Improvements +* Update the test suite to remove deprecated code. + [(#912)](https://github.com/PennyLaneAI/pennylane-lightning/pull/912) + * Skip the compilation of Lightning simulators and development requirements to boost the build of public docs up to 5x. [(#904)](https://github.com/PennyLaneAI/pennylane-lightning/pull/904) @@ -75,7 +78,7 @@ This release contains contributions from (in alphabetical order): -Ali Asadi, Amintor Dusko, Luis Alfredo Nuñez Meneses, Vincent Michaud-Rioux, Lee J. O'Riordan, Shuli Shu +Ali Asadi, Amintor Dusko, Luis Alfredo Nuñez Meneses, Vincent Michaud-Rioux, Lee J. O'Riordan, Mudit Pandey, Shuli Shu --- diff --git a/mpitests/test_adjoint_jacobian.py b/mpitests/test_adjoint_jacobian.py index a1d4be0260..6f3b5c7f5b 100644 --- a/mpitests/test_adjoint_jacobian.py +++ b/mpitests/test_adjoint_jacobian.py @@ -1378,7 +1378,7 @@ def circuit(params): def test_qubit_unitary(dev, n_targets): """Tests that ``qml.QubitUnitary`` can be included in circuits differentiated with the adjoint method.""" n_wires = len(dev.wires) - dev_def = qml.device("default.qubit.legacy", wires=n_wires) + dev_def = qml.device("default.qubit", wires=n_wires) h = 1e-3 if dev.R_DTYPE == np.float32 else 1e-7 c_dtype = np.complex64 if dev.R_DTYPE == np.float32 else np.complex128 @@ -1396,7 +1396,7 @@ def test_qubit_unitary(dev, n_targets): init_state = np.array(init_state, requires_grad=False, dtype=c_dtype) U = np.array(U, requires_grad=False, dtype=c_dtype) - obs = qml.operation.Tensor(*(qml.PauliZ(i) for i in range(n_wires))) + obs = qml.prod(*(qml.PauliZ(i) for i in range(n_wires))) def circuit(x): qml.StatePrep(init_state, wires=range(n_wires)) @@ -1444,7 +1444,7 @@ def test_diff_qubit_unitary(dev, n_targets): init_state = np.array(init_state, requires_grad=False, dtype=c_dtype) U = np.array(U, requires_grad=False, dtype=c_dtype) - obs = qml.operation.Tensor(*(qml.PauliZ(i) for i in range(n_wires))) + obs = qml.prod(*(qml.PauliZ(i) for i in range(n_wires))) def circuit(x, u_mat): qml.StatePrep(init_state, wires=range(n_wires)) diff --git a/pennylane_lightning/core/_version.py b/pennylane_lightning/core/_version.py index 065f0933a9..1d0b6fde2a 100644 --- a/pennylane_lightning/core/_version.py +++ b/pennylane_lightning/core/_version.py @@ -16,4 +16,4 @@ Version number (major.minor.patch[-label]) """ -__version__ = "0.39.0-dev24" +__version__ = "0.39.0-dev25" diff --git a/tests/test_adjoint_jacobian.py b/tests/test_adjoint_jacobian.py index 57f007a45f..83713b1c69 100644 --- a/tests/test_adjoint_jacobian.py +++ b/tests/test_adjoint_jacobian.py @@ -1544,7 +1544,7 @@ def test_qubit_unitary(n_targets): """Tests that ``qml.QubitUnitary`` can be included in circuits differentiated with the adjoint method.""" n_wires = 6 dev = qml.device(device_name, wires=n_wires) - dev_def = qml.device("default.qubit.legacy", wires=n_wires) + dev_def = qml.device("default.qubit", wires=n_wires) np.random.seed(1337) init_state = np.random.rand(2**n_wires) + 1j * np.random.rand(2**n_wires)