Skip to content

Commit 581dd3d

Browse files
authored
Fix Y-eigenstate convention in SparsePauliOp.as_paulis (Qiskit#13847)
`|r>` is the positive eigenstate of Y, not the negative one. The tests also asserted this backwards.
1 parent 1e634df commit 581dd3d

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

crates/accelerate/src/sparse_observable.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,8 @@ fn bit_term_as_pauli(bit: &BitTerm) -> &'static [(bool, Option<BitTerm>)] {
198198
BitTerm::Z => &[(true, Some(BitTerm::Z))],
199199
BitTerm::Plus => &[(true, None), (true, Some(BitTerm::X))],
200200
BitTerm::Minus => &[(true, None), (false, Some(BitTerm::X))],
201-
BitTerm::Left => &[(true, None), (true, Some(BitTerm::Y))],
202-
BitTerm::Right => &[(true, None), (false, Some(BitTerm::Y))],
201+
BitTerm::Right => &[(true, None), (true, Some(BitTerm::Y))],
202+
BitTerm::Left => &[(true, None), (false, Some(BitTerm::Y))],
203203
BitTerm::Zero => &[(true, None), (true, Some(BitTerm::Z))],
204204
BitTerm::One => &[(true, None), (false, Some(BitTerm::Z))],
205205
}

test/python/quantum_info/operators/symplectic/test_sparse_pauli_op.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ def test_from_sparse_observable(self):
392392
with self.subTest("XrZ"):
393393
obs = SparseObservable("XrZ")
394394
spo = SparsePauliOp.from_sparse_observable(obs)
395-
expected = SparsePauliOp(["XIZ", "XYZ"], coeffs=[0.5, -0.5])
395+
expected = SparsePauliOp(["XIZ", "XYZ"], coeffs=[0.5, 0.5])
396396

397397
# we don't guarantee the order of Paulis, so check equality by comparing
398398
# the matrix representation and that all Pauli strings are present

test/python/quantum_info/test_sparse_observable.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -2126,21 +2126,21 @@ def test_as_paulis(self):
21262126
expected = SparseObservable.from_sparse_list(
21272127
[
21282128
("", [], 1 / 8),
2129-
("Y", [2], -1 / 8),
2129+
("Y", [2], 1 / 8),
21302130
("YY", [3, 2], -1 / 8),
21312131
("Z", [0], 1 / 8),
2132-
("YZ", [2, 0], -1 / 8),
2132+
("YZ", [2, 0], 1 / 8),
21332133
("YYZ", [3, 2, 0], -1 / 8),
2134-
("Y", [3], 1 / 8),
2135-
("YZ", [3, 0], 1 / 8),
2134+
("Y", [3], -1 / 8),
2135+
("YZ", [3, 0], -1 / 8),
21362136
],
21372137
4,
21382138
)
21392139
self.assertEqual(expected.simplify(), obs_paulis.simplify())
21402140

21412141
# test multiple terms
21422142
with self.subTest(msg="+X + lY - ZI"):
2143-
obs = SparseObservable.from_list([("+X", 1), ("rY", 1), ("ZI", -1)])
2143+
obs = SparseObservable.from_list([("+X", 1), ("lY", 1), ("ZI", -1)])
21442144
obs_paulis = obs.as_paulis()
21452145

21462146
expected = SparseObservable.from_list(

0 commit comments

Comments
 (0)