Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion qiskit/quantum_info/operators/symplectic/base_pauli.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,5 +689,5 @@ def _count_y(x, z, dtype=None):
"""Count the number of I Pauli's"""
axis = 1
if dtype is None:
dtype = np.min_scalar_type(x.shape[axis])
dtype = np.int64(x.shape[axis])
return (x & z).sum(axis=axis, dtype=dtype)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
fixes:
- |
Fixed an issue with the a bug in the BasePauli/Pauli classes where the phase vector is sometimes set as
dtype uint8 instead of int64 leading to errors when calling the evolve function for circuits containing
gates that modify the pauli phase vector.
The dtype of the phase vector should always be the same, so that evolution and other methods that attempt
to inplace modify the vector don't cause exceptions for mismatched dtypes.
Fixed #8438 <https://github.com/Qiskit/qiskit-terra/issues/8438>
13 changes: 13 additions & 0 deletions test/python/quantum_info/operators/symplectic/test_pauli.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,19 @@ def test_barrier_delay_sim(self):
value = Pauli(circ)
self.assertEqual(value, target)

def test_evolve_clifford_with_phase(self):
"""Create circuit with gate that modifies Pauli phase"""
qc = QuantumCircuit(2)
qc.cz(0, 1)
op = Operator(qc)

pauli = random_pauli(2, seed=123)

value = Operator(pauli.evolve(qc))
target = op.adjoint().dot(pauli).dot(op)

self.assertEqual(value, target)


if __name__ == "__main__":
unittest.main()