From 9af4c37b91cd4914844a25858c13ef162e7033f7 Mon Sep 17 00:00:00 2001 From: Mudit Pandey Date: Tue, 13 Aug 2024 11:14:52 -0400 Subject: [PATCH] Update `Hermitian.decomposition` test to use `qml.matrix` (#6095) After the merge of #6062 , the legacy op math tests in the plugin test matrix fail (see [here](https://github.com/PennyLaneAI/pennylane/actions/runs/10362479768/job/28685492331)), since the test uses the `Operator.matrix` method to verify the decomposition, but the decomposed operator is a legacy `Hamiltonian` with new op math disabled, which doesn't have a matrix. This PR just updates the test to use `qml.matrix` instead of `Operator.matrix`. --- tests/ops/qubit/test_observables.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/ops/qubit/test_observables.py b/tests/ops/qubit/test_observables.py index 51c8996bb6f..30481460102 100644 --- a/tests/ops/qubit/test_observables.py +++ b/tests/ops/qubit/test_observables.py @@ -369,8 +369,8 @@ def test_hermitian_decomposition(self, observable): ) A_decomp = qml.Hermitian(observable, wires=list(range(num_wires))).decomposition() - assert np.allclose(A_decomp_static[0].matrix(), observable, rtol=0) - assert np.allclose(A_decomp[0].matrix(), observable, rtol=0) + assert np.allclose(qml.matrix(A_decomp_static[0]), observable, rtol=0) + assert np.allclose(qml.matrix(A_decomp[0]), observable, rtol=0) @pytest.mark.parametrize("observable, eigvals, eigvecs", EIGVALS_TEST_DATA) def test_hermitian_diagonalizing_gates(self, observable, eigvals, eigvecs, tol, mocker):