From f6ea486e2270615693b714f326b5f54884dd3064 Mon Sep 17 00:00:00 2001 From: Shelly Garion Date: Wed, 8 Feb 2023 14:48:06 +0000 Subject: [PATCH] updates following review --- qiskit/quantum_info/states/stabilizerstate.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/qiskit/quantum_info/states/stabilizerstate.py b/qiskit/quantum_info/states/stabilizerstate.py index 018a8997e4a7..18aa1d541ae1 100644 --- a/qiskit/quantum_info/states/stabilizerstate.py +++ b/qiskit/quantum_info/states/stabilizerstate.py @@ -274,12 +274,12 @@ def equiv(self, other): Returns: bool: True if other has a generating set that generates the same StabilizerState. - - Raises: - QiskitError: if other is not a StabilizerState. """ if not isinstance(other, StabilizerState): - raise QiskitError("Other is not a StabilizerState.") + try: + other = StabilizerState(other) + except QiskitError: + return False num_qubits = self.num_qubits if other.num_qubits != num_qubits: @@ -294,7 +294,7 @@ def equiv(self, other): # Check that each stabilizer from the original set commutes with each stabilizer # from the other set - if not (pauli_orig.commutes(pauli_other)).all(): + if not np.all([pauli.commutes(pauli_other) for pauli in pauli_orig]): return False # Compute the expected value of each stabilizer from the original set on the stabilizer state