PauliList¶
-
class
PauliList
(data)[source]¶ Bases:
qiskit.quantum_info.operators.symplectic.base_pauli.BasePauli
,qiskit.quantum_info.operators.mixins.linear.LinearMixin
,qiskit.quantum_info.operators.mixins.group.GroupMixin
List of N-qubit Pauli operators.
This class is an efficient representation of a list of
Pauli
operators. It supports 1D numpy array indexing returning aPauli
for integer indexes or aPauliList
for slice or list indices.Initialization
A PauliList object can be initialized in several ways.
For example,
import numpy as np from qiskit.quantum_info import Pauli, PauliList # 1. init from list[str] pauli_list = PauliList(["II", "+ZI", "-iYY"]) print("1. ", pauli_list) pauli1 = Pauli("iXI") pauli2 = Pauli("iZZ") # 2. init from Pauli print("2. ", PauliList(pauli1)) # 3. init from list[Pauli] print("3. ", PauliList([pauli1, pauli2])) # 4. init from np.ndarray z = np.array([[True, True], [False, False]]) x = np.array([[False, True], [True, False]]) phase = np.array([0, 1]) pauli_list = PauliList.from_symplectic(z, x) print("4. ", pauli_list)
1. ['II', 'ZI', '-iYY'] 2. ['iXI'] 3. ['iXI', 'iZZ'] 4. ['YZ', 'IX']
Data Access
The individual Paulis can be accessed and updated using the
[]
operator which accepts integer, lists, or slices for selecting subsets of PauliList. If integer is given, it returns Pauli not PauliList.pauli_list = PauliList(["XX", "ZZ", "IZ"]) print("Integer: ", repr(pauli_list[1])) print("List: ", repr(pauli_list[[0, 2]])) print("Slice: ", repr(pauli_list[0:2]))
Integer: Pauli('ZZ') List: PauliList(['XX', 'IZ']) Slice: PauliList(['XX', 'ZZ'])
Iteration
Rows in the Pauli table can be iterated over like a list. Iteration can also be done using the label or matrix representation of each row using the
label_iter()
andmatrix_iter()
methods.Initialize the PauliList.
- Parameters
data (Pauli or list) – input data for Paulis. If input is a list each item in the list must be a Pauli object or Pauli str.
- Raises
QiskitError – if input array is invalid shape.
- Additional Information:
The input array is not copied so multiple Pauli tables can share the same underlying array.
Methods
Return the adjoint of each Pauli in the list.
Return True if other Pauli that anticommutes with other.
Return indexes of rows that commute other.
Return indices for sorting the rows of the table.
Return True for each Pauli that commutes with other.
Return indexes of rows that commute other.
Return the composition self∘other for each Pauli in the list.
Return the conjugate of each Pauli in the list.
Make a deep copy of current operator.
Return a copy with Pauli rows deleted from table.
Return the composition other∘self for each Pauli in the list.
Entrywise comparison of Pauli equivalence up to global phase.
Evolve the Pauli by a Clifford.
Return the expand product of each Pauli in the list.
Construct a PauliList from a symplectic data.
Return tuple of input dimension for specified subsystems.
Insert Pauli’s into the table.
Return the inverse of each Pauli in the list.
Return a label representation iterator.
Return a matrix representation iterator.
Return tuple of output dimension for specified subsystems.
Return the compose of a operator with itself n times.
Return a shallow copy with reshaped input and output subsystem dimensions.
Sort the rows of the table.
Return the tensor product with each Pauli in the list.
Convert a PauliList to a list Pauli string labels.
Convert to a list or array of Pauli matrices.
Return the transpose of each Pauli in the list.
Return unique Paulis from the table.
Attributes
-
dim
¶ Return tuple (input_shape, output_shape).
-
num_qubits
¶ Return the number of qubits if a N-qubit operator or None otherwise.
-
phase
¶ Return the phase exponent of the PauliList.
-
qargs
¶ Return the qargs for the operator.
-
settings
¶ Return operator settings.
-
shape
¶ The full shape of the
array()
-
size
¶ The number of Pauli rows in the table.
-
x
¶ The x array for the symplectic representation.
-
z
¶ The z array for the symplectic representation.