Skip to content

Commit

Permalink
Fix failing tests; suppress deprecation warning
Browse files Browse the repository at this point in the history
  • Loading branch information
mudit2812 committed Sep 20, 2024
1 parent 59d0383 commit ae1e7b9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion tests/circuit_graph/test_circuit_graph_hash.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def test_serialize_numeric_arguments(self, queue, observable_queue, expected_str

observable1 = qml.PauliZ(wires=[0])
observable2 = qml.Hermitian(np.array([[1, 0], [0, -1]]), wires=[0])
observable3 = Tensor(qml.PauliZ(0) @ qml.PauliZ(1))
observable3 = Tensor(qml.PauliZ(0), qml.PauliZ(1))

numeric_observable_queue = [
(returntype1, observable1, "|||ObservableReturnTypes.Expectation!PauliZ[0]"),
Expand Down
5 changes: 4 additions & 1 deletion tests/pauli/test_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
test_diff_matrix2 = [[[-2, -2 + 1j], [-2 - 1j, 0]], [[2.5, -0.5], [-0.5, 2.5]]]

with warnings.catch_warnings():
warnings.simplefilter("ignore")
warnings.filterwarnings("ignore", "qml.ops.Hamiltonian uses", qml.PennyLaneDeprecationWarning)
hamiltonian_ps = (
(
qml.ops.Hamiltonian([], []),
Expand Down Expand Up @@ -553,6 +553,9 @@ def test_tensor_raises_error(self):
with pytest.raises(ValueError, match="Op must be a linear combination of"):
pauli_sentence(op)

@pytest.mark.filterwarnings(
"ignore:qml.ops.Hamiltonian uses:pennylane.PennyLaneDeprecationWarning"
)
@pytest.mark.usefixtures("use_legacy_and_new_opmath")
@pytest.mark.parametrize("op, ps", hamiltonian_ps)
def test_hamiltonian(self, op, ps):
Expand Down
6 changes: 5 additions & 1 deletion tests/pauli/test_pauli_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,11 @@ def test_pauli_word_to_string_tensor(self):
assert pauli_word_to_string(op) == "ZYX"

with qml.operation.disable_new_opmath_cm(warn=False):
PAULI_WORD_STRINGS_LEGACY = _make_pauli_word_strings()
with warnings.catch_warnings():
warnings.filterwarnings(
"ignore", "qml.ops.Hamiltonian uses", qml.PennyLaneDeprecationWarning
)
PAULI_WORD_STRINGS_LEGACY = _make_pauli_word_strings()

@pytest.mark.usefixtures("legacy_opmath_only")
@pytest.mark.parametrize("pauli_word,wire_map,expected_string", PAULI_WORD_STRINGS_LEGACY)
Expand Down
2 changes: 1 addition & 1 deletion tests/pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ filterwarnings =
ignore:Call to deprecated create function:DeprecationWarning
ignore:the imp module is deprecated:DeprecationWarning
error::pennylane.PennyLaneDeprecationWarning
; ignore:qml.ops.Hamiltonian uses the old approach:pennylane.PennyLaneDeprecationWarning
ignore:qml.ops.Hamiltonian uses the old approach:pennylane.PennyLaneDeprecationWarning
addopts = --benchmark-disable
xfail_strict=true

0 comments on commit ae1e7b9

Please sign in to comment.