Skip to content

Commit

Permalink
Update Hermitian.decomposition test to use qml.matrix (#6095)
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
mudit2812 authored Aug 13, 2024
1 parent f61c078 commit 9af4c37
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tests/ops/qubit/test_observables.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 9af4c37

Please sign in to comment.