Skip to content

Commit

Permalink
Add error handling for measured circs
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilkhatri committed Nov 27, 2024
1 parent 965b841 commit 9f5f8e6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lambeq/backend/pennylane.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
import sympy
import torch

from lambeq.backend.quantum import Scalar
from lambeq.backend.quantum import Scalar, Measure

if TYPE_CHECKING:
from lambeq.backend.quantum import Diagram
Expand Down Expand Up @@ -217,6 +217,10 @@ def to_pennylane(lambeq_circuit: Diagram, probabilities=False,
"""

if any(isinstance(box, Measure) for box in lambeq_circuit.boxes):
raise ValueError("Only pure circuits, or circuits with discards"
" are currently supported.")

tk_circ = lambeq_circuit.to_tk()
op_list, params_list, wires_list, symbols_set = (
extract_ops_from_tk(tk_circ)
Expand Down

0 comments on commit 9f5f8e6

Please sign in to comment.