Skip to content

Commit

Permalink
Track PL new stateprep error message (#1057)
Browse files Browse the repository at this point in the history
**Context:**
PL recently changed error messages for bad stateprep/basisstate use
cases (PennyLaneAI/pennylane#6021).
    We update our tests to agree with them.

**Benefits:** Frontend tests
`test_skip_initial_stateprep/TestPossibleErrors` can pass
  • Loading branch information
paul0403 authored Aug 27, 2024
1 parent b2a73b0 commit 5966ccb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .dep-versions
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ enzyme=v0.0.130

# For a custom PL version, update the package version here and at
# 'doc/requirements.txt
pennylane=0.38.0.dev21
pennylane=0.38.0.dev24

# For a custom LQ/LK version, update the package version here and at
# 'doc/requirements.txt'. Also, update the 'LIGHTNING_GIT_TAG' at
Expand Down
2 changes: 1 addition & 1 deletion doc/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ lxml_html_clean
--extra-index-url https://test.pypi.org/simple/
pennylane-lightning-kokkos==0.38.0-dev50
pennylane-lightning==0.38.0-dev50
pennylane==0.38.0.dev21
pennylane==0.38.0.dev24
7 changes: 3 additions & 4 deletions frontend/test/pytest/test_skip_initial_state_prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,10 @@ class TestPossibleErrors:

def test_array_less_than_size_basis_state(self):
"""Test what happens when the array is less than the size required.
In PennyLane the error raised is a ValueError, but all errors
in Catalyst that happen during runtime are RuntimeErrors.
In PennyLane the error raised is a ValueError.
"""

with pytest.raises(RuntimeError, match="must be of equal length"):
with pytest.raises(ValueError, match="State must be of length 2; got length 1"):

@qml.qjit
@qml.qnode(qml.device("lightning.qubit", wires=2))
Expand All @@ -200,7 +199,7 @@ def example_circuit():

def test_different_shape_state_prep(self):
"""Test that the same error is raised"""
with pytest.raises(ValueError, match="State vector must have shape"):
with pytest.raises(ValueError, match="State must be of length 2; got length 1"):

@qml.qjit
@qml.qnode(qml.device("lightning.qubit", wires=2))
Expand Down

0 comments on commit 5966ccb

Please sign in to comment.