Skip to content

Commit 8739a96

Browse files
committed
rework logic of _build_if_else_circuit a bit
1 parent 004ecce commit 8739a96

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

pytket/extensions/qiskit/qiskit_convert.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,8 @@ def _build_if_else_circuit(
527527
circ = circ_builder.circuit()
528528

529529
if isinstance(if_else_op.condition[0], Clbit):
530+
if len(bits) != 1:
531+
raise NotImplementedError("Conditions on multiple bits not yet supported")
530532
circ.add_circbox(
531533
circbox=if_box,
532534
args=qubits,
@@ -535,11 +537,6 @@ def _build_if_else_circuit(
535537
)
536538
# If we have an else_box defined, add it to the circuit
537539
if else_box is not None:
538-
if if_else_op.condition[1] not in {0, 1}:
539-
raise ValueError(
540-
"A bit must have condition value 0 or 1"
541-
+ f", got {if_else_op.condition[1]}"
542-
)
543540
circ.add_circbox(
544541
circbox=else_box,
545542
args=qubits,
@@ -560,6 +557,11 @@ def _build_if_else_circuit(
560557
args=qubits,
561558
condition=reg_neq(pytket_bit_reg, if_else_op.condition[1]),
562559
)
560+
else:
561+
raise TypeError(
562+
"Unrecognized type used to construct IfElseOp. Expected "
563+
+ f"ClBit or ClassicalRegister, got {type(if_else_op.condition[0])}"
564+
)
563565

564566
return circ
565567

0 commit comments

Comments
 (0)