From 616e376522298811cb213ab1013c6173f1fffd57 Mon Sep 17 00:00:00 2001 From: Andrew Eddins Date: Wed, 7 Aug 2024 10:29:15 -0400 Subject: [PATCH] add test with `simplify()` --- .../operators/symplectic/test_sparse_pauli_op.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/python/quantum_info/operators/symplectic/test_sparse_pauli_op.py b/test/python/quantum_info/operators/symplectic/test_sparse_pauli_op.py index 4c7a8677214a..c11975dd6ffb 100644 --- a/test/python/quantum_info/operators/symplectic/test_sparse_pauli_op.py +++ b/test/python/quantum_info/operators/symplectic/test_sparse_pauli_op.py @@ -1111,6 +1111,12 @@ def test_paulis_setter_absorbs_phase(self): self.assertTrue(np.allclose(op.coeffs, coeffs_init * np.array([-1j, 1j]))) # The phase of the input array is now zero: self.assertTrue(np.allclose(paulis_new.phase, np.array([0, 0]))) + + def test_paulis_setter_absorbs_phase_2(self): + """Test that `paulis` setter followed by `simplify()` handle phase OK.""" + spo = SparsePauliOp(['X', 'X']) + spo.paulis = ['X','-X'] + self.assertEqual(spo.simplify(), SparsePauliOp(['I'], coeffs=[0.+0.j])) def test_apply_layout_with_transpile(self): """Test the apply_layout method with a transpiler layout."""