From 9f5f8e6373d54786be7b400daee3a5ae84b3bd11 Mon Sep 17 00:00:00 2001 From: nikhilkhatri Date: Wed, 27 Nov 2024 15:42:04 +0000 Subject: [PATCH] Add error handling for measured circs --- lambeq/backend/pennylane.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lambeq/backend/pennylane.py b/lambeq/backend/pennylane.py index f4431f8c..0ec36d7a 100644 --- a/lambeq/backend/pennylane.py +++ b/lambeq/backend/pennylane.py @@ -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 @@ -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)