def test_sgn_prod(self): """Test sgn prod.""" p1 = Pauli(np.array([False]), np.array([True])) p2 = Pauli(np.array([True]), np.array([True])) self.log.info("sign product:") p3, sgn = Pauli.sgn_prod(p1, p2) self.log.info("p1: %s", p1.to_label()) self.log.info("p2: %s", p2.to_label()) self.log.info("p3: %s", p3.to_label()) self.log.info("sgn_prod(p1, p2): %s", str(sgn)) self.assertEqual(p1.to_label(), 'X') self.assertEqual(p2.to_label(), 'Y') self.assertEqual(p3.to_label(), 'Z') self.assertEqual(sgn, 1j) self.log.info("sign product reverse:") p3, sgn = Pauli.sgn_prod(p2, p1) self.log.info("p2: %s", p2.to_label()) self.log.info("p1: %s", p1.to_label()) self.log.info("p3: %s", p3.to_label()) self.log.info("sgn_prod(p2, p1): %s", str(sgn)) self.assertEqual(p1.to_label(), 'X') self.assertEqual(p2.to_label(), 'Y') self.assertEqual(p3.to_label(), 'Z') self.assertEqual(sgn, -1j)
def _one_body(edge_list, p, q, h1_pq): # pylint: disable=invalid-name """ Map the term a^\\dagger_p a_q + a^\\dagger_q a_p to qubit operator. Args: edge_list (numpy.ndarray): 2xE matrix, each indicates (from, to) pair p (int): index of the one body term q (int): index of the one body term h1_pq (complex): coefficient of the one body term at (p, q) Return: PauliSumOp: mapped qubit operator """ # Handle off-diagonal terms. if p != q: a_i, b_i = sorted([p, q]) b_a = edge_operator_bi(edge_list, a_i) b_b = edge_operator_bi(edge_list, b_i) a_ab = edge_operator_aij(edge_list, a_i, b_i) qubit_op = a_ab * b_b + b_a * a_ab final_coeff = -1j * 0.5 # Handle diagonal terms. else: b_p = edge_operator_bi(edge_list, p) v = np.zeros(edge_list.shape[1]) w = np.zeros(edge_list.shape[1]) id_pauli = Pauli(v, w) id_op = PauliSumOp.from_list([(id_pauli.to_label(), 1.0)]) qubit_op = id_op - b_p final_coeff = 0.5 qubit_op = (final_coeff * h1_pq) * qubit_op qubit_op.simplify() return qubit_op
def test_create_from_label(self): """Test creation from pauli label.""" label = 'IZXY' pauli = Pauli(label=label) self.assertEqual(pauli, self.ref_p) self.assertEqual(pauli.to_label(), self.ref_label) self.assertEqual(len(pauli), 4)
def evolve_pauli( pauli: Pauli, time: Union[float, ParameterExpression] = 1.0, cx_structure: str = "chain", label: Optional[str] = None, ) -> QuantumCircuit: r"""Construct a circuit implementing the time evolution of a single Pauli string. For a Pauli string :math:`P = \{I, X, Y, Z\}^{\otimes n}` on :math:`n` qubits and an evolution time :math:`t`, the returned circuit implements the unitary operation .. math:: U(t) = e^{-itP}. Since only a single Pauli string is evolved the circuit decomposition is exact. Args: pauli: The Pauli to evolve. time: The evolution time. cx_structure: Determine the structure of CX gates, can be either "chain" for next-neighbor connections or "fountain" to connect directly to the top qubit. label: A label for the gate. Returns: A quantum circuit implementing the time evolution of the Pauli. """ num_non_identity = len( [label for label in pauli.to_label() if label != "I"]) # first check, if the Pauli is only the identity, in which case the evolution only # adds a global phase if num_non_identity == 0: definition = QuantumCircuit(pauli.num_qubits, global_phase=-time) # if we evolve on a single qubit, if yes use the corresponding qubit rotation elif num_non_identity == 1: definition = _single_qubit_evolution(pauli, time) # same for two qubits, use Qiskit's native rotations elif num_non_identity == 2: definition = _two_qubit_evolution(pauli, time, cx_structure) # otherwise do basis transformation and CX chains else: definition = _multi_qubit_evolution(pauli, time, cx_structure) definition.name = f"exp(it {pauli.to_label()})" return definition
def diagonalizing_clifford(pauli: Pauli) -> QuantumCircuit: """Get the clifford circuit to diagonalize the Pauli operator. Args: pauli: The Pauli to diagonalize. Returns: A circuit to diagonalize. """ cliff = QuantumCircuit(pauli.num_qubits) for i, pauli_i in enumerate(reversed(pauli.to_label())): if pauli_i == "Y": cliff.sdg(i) if pauli_i in ["X", "Y"]: cliff.h(i) return cliff
def cnot_chain(pauli: Pauli) -> QuantumCircuit: """CX chain. For example, for the Pauli with the label 'XYZIX'. .. parsed-literal:: ┌───┐ q_0: ──────────┤ X ├ └─┬─┘ q_1: ────────────┼── ┌───┐ │ q_2: ─────┤ X ├──■── ┌───┐└─┬─┘ q_3: ┤ X ├──■─────── └─┬─┘ q_4: ──■──────────── Args: pauli: The Pauli for which to construct the CX chain. Returns: A circuit implementing the CX chain. """ chain = QuantumCircuit(pauli.num_qubits) control, target = None, None # iterate over the Pauli's and add CNOTs for i, pauli_i in enumerate(pauli.to_label()): i = pauli.num_qubits - i - 1 if pauli_i != "I": if control is None: control = i else: target = i if control is not None and target is not None: chain.cx(control, target) control = i target = None return chain
def cnot_fountain(pauli: Pauli) -> QuantumCircuit: """CX chain in the fountain shape. For example, for the Pauli with the label 'XYZIX'. .. parsed-literal:: ┌───┐┌───┐┌───┐ q_0: ┤ X ├┤ X ├┤ X ├ └─┬─┘└─┬─┘└─┬─┘ q_1: ──┼────┼────┼── │ │ │ q_2: ──■────┼────┼── │ │ q_3: ───────■────┼── │ q_4: ────────────■── Args: pauli: The Pauli for which to construct the CX chain. Returns: A circuit implementing the CX chain. """ chain = QuantumCircuit(pauli.num_qubits) control, target = None, None for i, pauli_i in enumerate(reversed(pauli.to_label())): if pauli_i != "I": if target is None: target = i else: control = i if control is not None and target is not None: chain.cx(control, target) control = None return chain
class TestPauli(QiskitTestCase): """Tests for Pauli class.""" def setUp(self): """Setup.""" z = np.asarray([1, 0, 1, 0]).astype(np.bool) x = np.asarray([1, 1, 0, 0]).astype(np.bool) self.ref_p = Pauli(z, x) self.ref_label = 'IZXY' self.ref_matrix = np.array( [[ 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. - 1.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j ], [ 0. + 0.j, 0. + 0.j, 0. + 1.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j ], [ 0. + 0.j, 0. - 1.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j ], [ 0. + 1.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j ], [ 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 1.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j ], [ 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. - 1.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j ], [ 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 1.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j ], [ 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. - 1.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j ], [ 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. - 1.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j ], [ 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 1.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j ], [ 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. - 1.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j ], [ 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 1.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j ], [ 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 1.j ], [ 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. - 1.j, 0. + 0.j ], [ 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 1.j, 0. + 0.j, 0. + 0.j ], [ 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. + 0.j, 0. - 1.j, 0. + 0.j, 0. + 0.j, 0. + 0.j ]]) def test_create_from_label(self): """Test creation from pauli label.""" label = 'IZXY' pauli = Pauli(label=label) self.assertEqual(pauli, self.ref_p) self.assertEqual(pauli.to_label(), self.ref_label) self.assertEqual(len(pauli), 4) def test_create_from_z_x(self): """Test creation for boolean vector.""" self.assertEqual(self.ref_p.to_label(), 'IZXY') self.assertEqual(len(self.ref_p), 4) def test_repr(self): """Test __repr__.""" p = repr(self.ref_p) self.assertEqual( p, "Pauli(z=[True, False, True, False], x=[True, True, False, False])" ) def test_random_pauli(self): """Test random pauli creation.""" length = 4 q = Pauli.random(length, seed=42) self.log.info(q) self.assertEqual(q.numberofqubits, length) self.assertEqual(len(q.z), length) self.assertEqual(len(q.x), length) self.assertEqual(len(q.to_label()), length) self.assertEqual(len(q.to_matrix()), 2**length) def test_mul(self): """Test multiplication.""" p1 = self.ref_p p2 = Pauli.from_label('ZXXI') p3 = p1 * p2 self.assertEqual(len(p3), 4) self.assertEqual(p3.to_label(), 'ZYIY') def test_imul(self): """Test in-place multiplication.""" p1 = self.ref_p p2 = Pauli.from_label('ZXXI') p3 = deepcopy(p2) p2 *= p1 self.assertTrue(p2 != p3) self.assertEqual(p2.to_label(), 'ZYIY') def test_equality_equal(self): """Test equality operator: equal Paulis.""" p1 = self.ref_p p2 = deepcopy(p1) self.assertTrue(p1 == p2) self.assertEqual(p1.to_label(), self.ref_label) self.assertEqual(p2.to_label(), self.ref_label) def test_equality_different(self): """Test equality operator: different Paulis.""" p1 = self.ref_p p2 = deepcopy(p1) p2.update_z(True, 1) self.assertFalse(p1 == p2) self.assertEqual(p1.to_label(), self.ref_label) self.assertEqual(p2.to_label(), 'IZYY') def test_inequality_equal(self): """Test inequality operator: equal Paulis.""" p1 = self.ref_p p2 = deepcopy(p1) self.assertFalse(p1 != p2) def test_inequality_different(self): """Test inequality operator: different Paulis.""" p1 = self.ref_p p2 = deepcopy(p1) p2.update_x(False, 1) self.assertTrue(p1 != p2) self.assertEqual(p2.to_label(), 'IZIY') def test_update_z(self): """Test update_z method.""" updated_z = np.asarray([0, 0, 0, 0]).astype(np.bool) self.ref_p.update_z(updated_z) np.testing.assert_equal(self.ref_p.z, np.asarray([False, False, False, False])) self.assertEqual(self.ref_p.to_label(), 'IIXX') def test_update_z_2(self): """Test update_z method, update partial z.""" updated_z = np.asarray([0, 1]).astype(np.bool) self.ref_p.update_z(updated_z, [0, 1]) np.testing.assert_equal(self.ref_p.z, np.asarray([False, True, True, False])) self.assertEqual(self.ref_p.to_label(), 'IZYX') def test_update_x(self): """Test update_x method.""" updated_x = np.asarray([0, 1, 0, 1]).astype(np.bool) self.ref_p.update_x(updated_x) np.testing.assert_equal(self.ref_p.x, np.asarray([False, True, False, True])) self.assertEqual(self.ref_p.to_label(), 'XZXZ') def test_update_x_2(self): """Test update_x method, update partial x.""" updated_x = np.asarray([0, 1]).astype(np.bool) self.ref_p.update_x(updated_x, [1, 2]) np.testing.assert_equal(self.ref_p.x, np.asarray([True, False, True, False])) self.assertEqual(self.ref_p.to_label(), 'IYIY') def test_to_matrix(self): """Test pauli to matrix.""" np.testing.assert_allclose(self.ref_p.to_matrix(), self.ref_matrix) def test_delete_qubit(self): """Test deleting single qubit.""" p1 = self.ref_p p2 = deepcopy(p1) p2.delete_qubits(0) self.assertTrue(p1 != p2) self.assertEqual(len(p2), 3) self.assertEqual(p2.to_label(), 'IZX') def test_delete_qubits(self): """Test deleting multiple qubits.""" p1 = self.ref_p p2 = deepcopy(p1) p2.delete_qubits([0, 2]) self.assertTrue(p1 != p2) self.assertEqual(len(p2), 2) self.assertEqual(p2.to_label(), 'IX') def test_append_pauli_labels(self): """Test appending paulis via labels.""" p1 = self.ref_p p2 = deepcopy(p1) p2.append_paulis(pauli_labels=['Z', 'Y', 'I']) self.assertTrue(p1 != p2) self.assertEqual(len(p2), 7) self.assertEqual(p2.to_label(), 'IYZ' + self.ref_label) def test_append_paulis(self): """Test appending paulis via pauli object.""" p1 = self.ref_p p2 = deepcopy(p1) p2.append_paulis(paulis=p1) self.assertTrue(p1 != p2) self.assertEqual(len(p2), 8) self.assertEqual(p2.to_label(), self.ref_label + self.ref_label) def test_insert_pauli_labels_1(self): """Test inserting paulis via labels.""" p2 = deepcopy(self.ref_p) p2.insert_paulis(indices=[1, 2], pauli_labels=['Y', 'I']) self.assertTrue(self.ref_p != p2) self.assertEqual(len(p2), 6) self.assertEqual(p2.to_label(), 'IZIXYY') def test_insert_pauli_labels_2(self): """Test inserting paulis via labels.""" p2 = deepcopy(self.ref_p) p2.insert_paulis(indices=[3, 2], pauli_labels=['Y', 'I']) self.assertTrue(self.ref_p != p2) self.assertEqual(len(p2), 6) self.assertEqual(p2.to_label(), 'IYZIXY') def test_insert_paulis(self): """Test inserting paulis via pauli object.""" p1 = deepcopy(self.ref_p) new_p = Pauli.from_label('XY') p1.insert_paulis(indices=[0], paulis=new_p) self.assertTrue(p1 != self.ref_p) self.assertEqual(len(p1), 6) self.assertEqual(p1.to_label(), self.ref_label + 'XY') def test_kron(self): """Test kron production.""" p1 = deepcopy(self.ref_p) p2 = self.ref_p p2.kron(p1) self.assertTrue(p1 != p2) self.assertEqual(len(p2), 8) self.assertEqual(p2.to_label(), self.ref_label + self.ref_label) def test_pauli_single(self): """Test pauli single.""" num_qubits = 5 pz = Pauli.pauli_single(num_qubits, 2, 'Z') self.assertTrue(pz.to_label(), 'IIIZI') py = Pauli.pauli_single(num_qubits, 4, 'Y') self.assertTrue(py.to_label(), 'IYIII') px = Pauli.pauli_single(num_qubits, 3, 'X') self.assertTrue(px.to_label(), 'IIXII') def test_pauli_group(self): """Test pauli group.""" self.log.info("Group in tensor order:") expected = [ 'III', 'XII', 'YII', 'ZII', 'IXI', 'XXI', 'YXI', 'ZXI', 'IYI', 'XYI', 'YYI', 'ZYI', 'IZI', 'XZI', 'YZI', 'ZZI', 'IIX', 'XIX', 'YIX', 'ZIX', 'IXX', 'XXX', 'YXX', 'ZXX', 'IYX', 'XYX', 'YYX', 'ZYX', 'IZX', 'XZX', 'YZX', 'ZZX', 'IIY', 'XIY', 'YIY', 'ZIY', 'IXY', 'XXY', 'YXY', 'ZXY', 'IYY', 'XYY', 'YYY', 'ZYY', 'IZY', 'XZY', 'YZY', 'ZZY', 'IIZ', 'XIZ', 'YIZ', 'ZIZ', 'IXZ', 'XXZ', 'YXZ', 'ZXZ', 'IYZ', 'XYZ', 'YYZ', 'ZYZ', 'IZZ', 'XZZ', 'YZZ', 'ZZZ' ] grp = pauli_group(3, case='tensor') for j in grp: self.log.info('==== j (tensor order) ====') self.log.info(j.to_label()) self.assertEqual(expected.pop(0)[::-1], j.to_label()) self.log.info("Group in weight order:") expected = [ 'III', 'XII', 'YII', 'ZII', 'IXI', 'IYI', 'IZI', 'IIX', 'IIY', 'IIZ', 'XXI', 'YXI', 'ZXI', 'XYI', 'YYI', 'ZYI', 'XZI', 'YZI', 'ZZI', 'XIX', 'YIX', 'ZIX', 'IXX', 'IYX', 'IZX', 'XIY', 'YIY', 'ZIY', 'IXY', 'IYY', 'IZY', 'XIZ', 'YIZ', 'ZIZ', 'IXZ', 'IYZ', 'IZZ', 'XXX', 'YXX', 'ZXX', 'XYX', 'YYX', 'ZYX', 'XZX', 'YZX', 'ZZX', 'XXY', 'YXY', 'ZXY', 'XYY', 'YYY', 'ZYY', 'XZY', 'YZY', 'ZZY', 'XXZ', 'YXZ', 'ZXZ', 'XYZ', 'YYZ', 'ZYZ', 'XZZ', 'YZZ', 'ZZZ' ] grp = pauli_group(3, case='weight') for j in grp: self.log.info('==== j (weight order) ====') self.log.info(j.to_label()) self.assertEqual(expected.pop(0)[::-1], j.to_label()) def test_sgn_prod(self): """Test sgn prod.""" p1 = Pauli(np.array([False]), np.array([True])) p2 = Pauli(np.array([True]), np.array([True])) self.log.info("sign product:") p3, sgn = Pauli.sgn_prod(p1, p2) self.log.info("p1: %s", p1.to_label()) self.log.info("p2: %s", p2.to_label()) self.log.info("p3: %s", p3.to_label()) self.log.info("sgn_prod(p1, p2): %s", str(sgn)) self.assertEqual(p1.to_label(), 'X') self.assertEqual(p2.to_label(), 'Y') self.assertEqual(p3.to_label(), 'Z') self.assertEqual(sgn, 1j) self.log.info("sign product reverse:") p3, sgn = Pauli.sgn_prod(p2, p1) self.log.info("p2: %s", p2.to_label()) self.log.info("p1: %s", p1.to_label()) self.log.info("p3: %s", p3.to_label()) self.log.info("sgn_prod(p2, p1): %s", str(sgn)) self.assertEqual(p1.to_label(), 'X') self.assertEqual(p2.to_label(), 'Y') self.assertEqual(p3.to_label(), 'Z') self.assertEqual(sgn, -1j)
def qubit_tapering(operator, cliffords, sq_list, tapering_values): if len(cliffords) == 0 or len(sq_list) == 0 or len(tapering_values) == 0: logger.warning( "Cliffords, single qubit list and tapering values cannot be empty.\n" "Return the original operator instead.") return operator if len(cliffords) != len(sq_list): logger.warning( "Number of Clifford unitaries has to be the same as length of single" "qubit list and tapering values.\n" "Return the original operator instead.") return operator if len(sq_list) != len(tapering_values): logger.warning( "Number of Clifford unitaries has to be the same as length of single" "qubit list and tapering values.\n" "Return the original operator instead.") return operator if operator.is_empty(): logger.warning( "The operator is empty, return the empty operator directly.") return operator operator.to_paulis() for clifford in cliffords: operator = clifford * operator * clifford operator.zeros_coeff_elimination() operator_out = Operator(paulis=[]) X_1 = range(14) def diff(first, second): second = set(second) return [item for item in first if item not in second] # print(diff(X_1,X_list)) for pauli_term in operator.paulis: coeff_out = pauli_term[0] for idx, qubit_idx in enumerate(sq_list): if not (not pauli_term[1].z[qubit_idx] and not pauli_term[1].x[qubit_idx]): coeff_out = tapering_values[idx] * coeff_out z_temp = np.delete(pauli_term[1].z.copy(), np.asarray(sq_list)) x_temp = np.delete(pauli_term[1].x.copy(), np.asarray(sq_list)) # print(sq_list) z_temp_1 = pauli_term[1].z[sq_list] x_temp_1 = pauli_term[1].x[sq_list] p = Pauli(z_temp_1, x_temp_1) if p.to_label().find('Z') != -1: print(p.to_label()) elif p.to_label().find('Y') != -1: print(p.to_lable()) if p.to_label().find('Y') != -1: print('Something is wrong! There is a Y in the string') if p.to_label().find('Z') != -1: print('Something is wrong! There is a Z in the string') # print(p.to_label()) # print(coeff_out) pauli_term_out = [coeff_out, Pauli(z_temp, x_temp)] operator_out += Operator(paulis=[pauli_term_out]) operator_out.zeros_coeff_elimination() return operator_out