diff --git a/src/qiskit_qec/operators/pauli.py b/src/qiskit_qec/operators/pauli.py index 610583f5..46aac06d 100644 --- a/src/qiskit_qec/operators/pauli.py +++ b/src/qiskit_qec/operators/pauli.py @@ -99,8 +99,7 @@ def __init__( ) elif isinstance(data, str): - matrix, phase_exp = pauli_rep.str2symplectic( - data, qubit_order=input_qubit_order) + matrix, phase_exp = pauli_rep.str2symplectic(data, qubit_order=input_qubit_order) elif isinstance(data, ScalarOp): matrix, phase_exp = pauli_rep.scalar_op2symplectic( data, output_encoding=pauli_rep.INTERNAL_PHASE_ENCODING @@ -111,12 +110,10 @@ def __init__( if z is None: # Using old Pauli initialization with positional args instead of kwargs z = data - matrix, phase_exp = self._from_split_array_deprecated( - z, x, phase_exp) + matrix, phase_exp = self._from_split_array_deprecated(z, x, phase_exp) elif label is not None: # DEPRECATED - matrix, phase_exp = self._from_label_deprecated( - label, qubit_order=input_qubit_order) + matrix, phase_exp = self._from_label_deprecated(label, qubit_order=input_qubit_order) else: raise QiskitError("Invalid input data for Pauli.") @@ -200,11 +197,11 @@ def x(self, val): @property def z(self): """The z vector for the Pauli.""" - return self.matrix[:, self.num_qubits:][0] + return self.matrix[:, self.num_qubits :][0] @z.setter def z(self, val): - self.matrix[:, self.num_qubits:][0] = val + self.matrix[:, self.num_qubits :][0] = val # --------------------------------------------------------------------- # Magic Methods @@ -221,7 +218,7 @@ def __str__(self): and self.num_qubits > self._truncate__ and BasePauli.EXTERNAL_SYNTAX == pauli_rep.PRODUCT_SYNTAX ): - front = self[-self._truncate__:].to_label() + front = self[-self._truncate__ :].to_label() return front + "..." return self.to_label() @@ -322,7 +319,7 @@ def _getitem(self, i): Returns: Pauli: Pauli acting on qubit i """ - return Pauli(self.matrix[0][i: self.matrix.shape[1]: self.num_qubits]) + return Pauli(self.matrix[0][i : self.matrix.shape[1] : self.num_qubits]) def _fast_getitem_str(self, i): """Get Pauli for qubit i @@ -521,8 +518,7 @@ def to_instruction(self): ) if len(pauli) == 1: - gate = {"I": IGate(), "X": XGate(), "Y": YGate(), - "Z": ZGate()}[pauli] + gate = {"I": IGate(), "X": XGate(), "Y": YGate(), "Z": ZGate()}[pauli] else: gate = PauliGate(pauli) if not phase_exp: @@ -700,8 +696,7 @@ def instrs2symplectic(instr: Union[Instruction, QuantumCircuit]): instr = instr.definition # Initialize identity Pauli - ret = Pauli(np.zeros((1, 2 * instr.num_qubits), - dtype=bool), phase_exp=0) + ret = Pauli(np.zeros((1, 2 * instr.num_qubits), dtype=bool), phase_exp=0) # Add circuit global phase if specified if instr.global_phase: ret._phase_exp = pauli_rep.cpx2exp( @@ -953,8 +948,7 @@ def insert_paulis(self, indices=None, paulis=None, pauli_labels=None): """ if pauli_labels is not None: if paulis is not None: - raise QiskitError( - "Please only provide either `paulis` or `pauli_labels`") + raise QiskitError("Please only provide either `paulis` or `pauli_labels`") if isinstance(pauli_labels, str): pauli_labels = list(pauli_labels) # since pauli label is in reversed order. @@ -1038,8 +1032,7 @@ def pauli_single(cls, num_qubits, index, pauli_label): Pauli: single qubit pauli """ tmp = Pauli(pauli_label) - ret = Pauli((np.zeros(num_qubits, dtype=bool), - np.zeros(num_qubits, dtype=bool))) + ret = Pauli((np.zeros(num_qubits, dtype=bool), np.zeros(num_qubits, dtype=bool))) ret.x[index] = tmp.x[0] ret.z[index] = tmp.z[0] ret.phase = tmp.phase @@ -1064,8 +1057,7 @@ def random(cls, num_qubits, seed=None): Pauli: the random pauli """ # pylint: disable=cyclic-import - from qiskit.quantum_info.operators.symplectic.random import \ - random_pauli + from qiskit.quantum_info.operators.symplectic.random import random_pauli return random_pauli(num_qubits, group_phase=False, seed=seed) diff --git a/test/utils/test_visualization.py b/test/utils/test_visualization.py index d83599f8..e9ce3ec0 100644 --- a/test/utils/test_visualization.py +++ b/test/utils/test_visualization.py @@ -61,10 +61,3 @@ def next_frame(_): engine.screen.pixel[0, engine.size - 1].button.description == "hello", "Pixel in game engine not displaying correct text", ) - - -if __name__ == "__main__": - # for testing locally. JUPYTER_PLATFORM_DIRS is set via tox when using tox - import os - - os.environ["JUPYTER_PLATFORM_DIRS"] = 1