Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pauli_basis deprecation (backport #8905) #8909

Merged
merged 1 commit into from
Oct 14, 2022
Merged
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
14 changes: 12 additions & 2 deletions qiskit/quantum_info/operators/symplectic/pauli_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,30 @@
PauliList utility functions.
"""

import warnings
from qiskit.quantum_info.operators.symplectic.pauli_list import PauliList


def pauli_basis(num_qubits, weight=False):
def pauli_basis(num_qubits, weight=False, pauli_list=None):
"""Return the ordered PauliTable or PauliList for the n-qubit Pauli basis.

Args:
num_qubits (int): number of qubits
weight (bool): if True optionally return the basis sorted by Pauli weight
rather than lexicographic order (Default: False)
pauli_list (bool): [Deprecated] This argument is deprecated and remains
for backwards compatability. It has no effect.

Returns:
PauliTable, PauliList: the Paulis for the basis
PauliList: the Paulis for the basis
"""
if pauli_list is not None:
warnings.warn(
"The `pauli_list` kwarg is deprecated as of Qiskit Terra 0.22 and "
"no longer has an effect as `pauli_basis` always returns a PauliList.",
DeprecationWarning,
stacklevel=2,
)
pauli_1q = PauliList(["I", "X", "Y", "Z"])
if num_qubits == 1:
return pauli_1q
Expand Down
11 changes: 11 additions & 0 deletions releasenotes/notes/fix-pauli-basis-dep-27c0a4506ad38d2c.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
deprecations:
- |
The ``pauli_list`` kwarg of :func:`.pauli_basis` has been deprecated as
:func:`.pauli_basis` now always returns a :class:`.PauliList`.
fixes:
- |
Fixes the removal of ``pauli_list`` kwarg of :func:`.pauli_basis` which
broke existing code using the ``pauli_list=True`` future compatibility on
upgrade to Qiskit Terra 0.22. This kwarg has been added back to the the
function with a deprecation warning instead.