Skip to content

Commit 88b5b0a

Browse files
committed
adding some safe guards
1 parent 3e776c3 commit 88b5b0a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/bloqade/pyqrack/device.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,15 @@ def pauli_expectation(pauli: list[Pauli], qubits: list[PyQrackQubit]) -> float:
8282
raise ValueError("Length of Pauli and qubits must match.")
8383

8484
sim_reg = qubits[0].sim_reg
85+
86+
if any(qubit.sim_reg is not sim_reg for qubit in qubits):
87+
raise ValueError("All qubits must belong to the same simulator register.")
88+
8589
qubit_ids = [qubit.addr for qubit in qubits]
8690

91+
if len(qubit_ids) != len(set(qubit_ids)):
92+
raise ValueError("Qubits must be unique.")
93+
8794
return sim_reg.pauli_expectation(pauli, qubit_ids)
8895

8996

0 commit comments

Comments
 (0)