Fix phase of pauli_list.insert(..., qubit=True)
for length-1 pauli_list
(backport #13624)
#13637
+23
−8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fix #13623.
Details and comments
Fixes bug in
PauliList.insert(..., qubit=True)
method, where the outputPauliList
would have a 2Dphase
attribute (should be 1D).The bug was in a line of code manually broadcasting the
phase
of thePauliList
being inserted to match the shape of thephase
of the originalPauliList
. This PR removes this line of code, and lets numpy handle the broadcasting ofphase
.This PR also adds a check in
PauliList.from_symplectic(..., phase)
to rejectphase
if it is a multi-dimensional array, and a test for issue #13623.(For the record, I messed up the commit message in 92161ec. The simpler
if/elif
case is indeed moved to be first, but in the commit message I mixed up the two cases).This is an automatic backport of pull request #13624 done by [Mergify](https://mergify.com).