812 lines
25 KiB
Plaintext
812 lines
25 KiB
Plaintext
---
|
||
title: PauliList (v0.31)
|
||
description: API reference for qiskit.quantum_info.PauliList in qiskit v0.31
|
||
in_page_toc_min_heading_level: 1
|
||
python_api_type: class
|
||
python_api_name: qiskit.quantum_info.PauliList
|
||
---
|
||
|
||
# PauliList
|
||
|
||
<Class id="qiskit.quantum_info.PauliList" isDedicatedPage={true} github="https://github.com/qiskit/qiskit/tree/stable/0.18/qiskit/quantum_info/operators/symplectic/pauli_list.py" signature="PauliList(data)" modifiers="class">
|
||
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`](qiskit.quantum_info.Pauli "qiskit.quantum_info.Pauli") operators. It supports 1D numpy array indexing returning a [`Pauli`](qiskit.quantum_info.Pauli "qiskit.quantum_info.Pauli") for integer indexes or a [`PauliList`](#qiskit.quantum_info.PauliList "qiskit.quantum_info.PauliList") for slice or list indices.
|
||
|
||
**Initialization**
|
||
|
||
A PauliList object can be initialized in several ways.
|
||
|
||
> **`PauliList(list[str])`**
|
||
>
|
||
> where strings are same representation with [`Pauli`](qiskit.quantum_info.Pauli "qiskit.quantum_info.Pauli").
|
||
>
|
||
> **`PauliList(Pauli) and PauliList(list[Pauli])`**
|
||
>
|
||
> where Pauli is [`Pauli`](qiskit.quantum_info.Pauli "qiskit.quantum_info.Pauli").
|
||
>
|
||
> **`PauliList.from_symplectic(z, x, phase)`**
|
||
>
|
||
> where `z` and `x` are 2 dimensional boolean `numpy.ndarrays` and `phase` is an integer in `[0, 1, 2, 3]`.
|
||
|
||
For example,
|
||
|
||
```python
|
||
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.
|
||
|
||
```python
|
||
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()`](qiskit.quantum_info.PauliList#label_iter "qiskit.quantum_info.PauliList.label_iter") and [`matrix_iter()`](qiskit.quantum_info.PauliList#matrix_iter "qiskit.quantum_info.PauliList.matrix_iter") methods.
|
||
|
||
Initialize the PauliList.
|
||
|
||
**Parameters**
|
||
|
||
**data** ([*Pauli*](qiskit.quantum_info.Pauli "qiskit.quantum_info.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
|
||
|
||
<span id="qiskit-quantum-info-paulilist-adjoint" />
|
||
|
||
### adjoint
|
||
|
||
<Function id="qiskit.quantum_info.PauliList.adjoint" signature="PauliList.adjoint()">
|
||
Return the adjoint of each Pauli in the list.
|
||
</Function>
|
||
|
||
<span id="qiskit-quantum-info-paulilist-anticommutes" />
|
||
|
||
### anticommutes
|
||
|
||
<Function id="qiskit.quantum_info.PauliList.anticommutes" signature="PauliList.anticommutes(other, qargs=None)">
|
||
Return True if other Pauli that anticommutes with other.
|
||
|
||
**Parameters**
|
||
|
||
* **other** ([*PauliList*](qiskit.quantum_info.PauliList "qiskit.quantum_info.PauliList")) – another PauliList operator.
|
||
* **qargs** (*list*) – qubits to apply dot product on (default: None).
|
||
|
||
**Returns**
|
||
|
||
True if Pauli’s anticommute, False if they commute.
|
||
|
||
**Return type**
|
||
|
||
bool
|
||
</Function>
|
||
|
||
<span id="qiskit-quantum-info-paulilist-anticommutes-with-all" />
|
||
|
||
### anticommutes\_with\_all
|
||
|
||
<Function id="qiskit.quantum_info.PauliList.anticommutes_with_all" signature="PauliList.anticommutes_with_all(other)">
|
||
Return indexes of rows that commute other.
|
||
|
||
If other is a multi-row Pauli list the returned vector indexes rows of the current PauliList that anti-commute with *all* Pauli’s in other. If no rows satisfy the condition the returned array will be empty.
|
||
|
||
**Parameters**
|
||
|
||
**other** ([*PauliList*](qiskit.quantum_info.PauliList "qiskit.quantum_info.PauliList")) – a single Pauli or multi-row PauliList.
|
||
|
||
**Returns**
|
||
|
||
index array of the anti-commuting rows.
|
||
|
||
**Return type**
|
||
|
||
array
|
||
</Function>
|
||
|
||
<span id="qiskit-quantum-info-paulilist-argsort" />
|
||
|
||
### argsort
|
||
|
||
<Function id="qiskit.quantum_info.PauliList.argsort" signature="PauliList.argsort(weight=False, phase=False)">
|
||
Return indices for sorting the rows of the table.
|
||
|
||
The default sort method is lexicographic sorting by qubit number. By using the weight kwarg the output can additionally be sorted by the number of non-identity terms in the Pauli, where the set of all Pauli’s of a given weight are still ordered lexicographically.
|
||
|
||
**Parameters**
|
||
|
||
* **weight** (*bool*) – Optionally sort by weight if True (Default: False).
|
||
* **phase** (*bool*) – Optionally sort by phase before weight or order (Default: False).
|
||
|
||
**Returns**
|
||
|
||
the indices for sorting the table.
|
||
|
||
**Return type**
|
||
|
||
array
|
||
</Function>
|
||
|
||
<span id="qiskit-quantum-info-paulilist-commutes" />
|
||
|
||
### commutes
|
||
|
||
<Function id="qiskit.quantum_info.PauliList.commutes" signature="PauliList.commutes(other, qargs=None)">
|
||
Return True for each Pauli that commutes with other.
|
||
|
||
**Parameters**
|
||
|
||
* **other** ([*PauliList*](qiskit.quantum_info.PauliList "qiskit.quantum_info.PauliList")) – another PauliList operator.
|
||
* **qargs** (*list*) – qubits to apply dot product on (default: None).
|
||
|
||
**Returns**
|
||
|
||
True if Pauli’s commute, False if they anti-commute.
|
||
|
||
**Return type**
|
||
|
||
bool
|
||
</Function>
|
||
|
||
<span id="qiskit-quantum-info-paulilist-commutes-with-all" />
|
||
|
||
### commutes\_with\_all
|
||
|
||
<Function id="qiskit.quantum_info.PauliList.commutes_with_all" signature="PauliList.commutes_with_all(other)">
|
||
Return indexes of rows that commute other.
|
||
|
||
If other is a multi-row Pauli list the returned vector indexes rows of the current PauliList that commute with *all* Pauli’s in other. If no rows satisfy the condition the returned array will be empty.
|
||
|
||
**Parameters**
|
||
|
||
**other** ([*PauliList*](qiskit.quantum_info.PauliList "qiskit.quantum_info.PauliList")) – a single Pauli or multi-row PauliList.
|
||
|
||
**Returns**
|
||
|
||
index array of the commuting rows.
|
||
|
||
**Return type**
|
||
|
||
array
|
||
</Function>
|
||
|
||
<span id="qiskit-quantum-info-paulilist-compose" />
|
||
|
||
### compose
|
||
|
||
<Function id="qiskit.quantum_info.PauliList.compose" signature="PauliList.compose(other, qargs=None, front=False, inplace=False)">
|
||
Return the composition self∘other for each Pauli in the list.
|
||
|
||
**Parameters**
|
||
|
||
* **other** ([*PauliList*](qiskit.quantum_info.PauliList "qiskit.quantum_info.PauliList")) – another PauliList.
|
||
* **qargs** (*None or list*) – qubits to apply dot product on (Default: None).
|
||
* **front** (*bool*) – If True use dot composition method \[default: False].
|
||
* **inplace** (*bool*) – If True update in-place (default: False).
|
||
|
||
**Returns**
|
||
|
||
the list of composed Paulis.
|
||
|
||
**Return type**
|
||
|
||
[PauliList](qiskit.quantum_info.PauliList "qiskit.quantum_info.PauliList")
|
||
|
||
**Raises**
|
||
|
||
**QiskitError** – if other cannot be converted to a PauliList, does not have either 1 or the same number of Paulis as the current list, or has the wrong number of qubits for the specified qargs.
|
||
</Function>
|
||
|
||
<span id="qiskit-quantum-info-paulilist-conjugate" />
|
||
|
||
### conjugate
|
||
|
||
<Function id="qiskit.quantum_info.PauliList.conjugate" signature="PauliList.conjugate()">
|
||
Return the conjugate of each Pauli in the list.
|
||
</Function>
|
||
|
||
<span id="qiskit-quantum-info-paulilist-copy" />
|
||
|
||
### copy
|
||
|
||
<Function id="qiskit.quantum_info.PauliList.copy" signature="PauliList.copy()">
|
||
Make a deep copy of current operator.
|
||
</Function>
|
||
|
||
<span id="qiskit-quantum-info-paulilist-delete" />
|
||
|
||
### delete
|
||
|
||
<Function id="qiskit.quantum_info.PauliList.delete" signature="PauliList.delete(ind, qubit=False)">
|
||
Return a copy with Pauli rows deleted from table.
|
||
|
||
When deleting qubits the qubit index is the same as the column index of the underlying `X` and `Z` arrays.
|
||
|
||
**Parameters**
|
||
|
||
* **ind** (*int or list*) – index(es) to delete.
|
||
* **qubit** (*bool*) – if True delete qubit columns, otherwise delete Pauli rows (Default: False).
|
||
|
||
**Returns**
|
||
|
||
the resulting table with the entries removed.
|
||
|
||
**Return type**
|
||
|
||
[PauliList](qiskit.quantum_info.PauliList "qiskit.quantum_info.PauliList")
|
||
|
||
**Raises**
|
||
|
||
**QiskitError** – if ind is out of bounds for the array size or number of qubits.
|
||
</Function>
|
||
|
||
<span id="qiskit-quantum-info-paulilist-dot" />
|
||
|
||
### dot
|
||
|
||
<Function id="qiskit.quantum_info.PauliList.dot" signature="PauliList.dot(other, qargs=None, inplace=False)">
|
||
Return the composition other∘self for each Pauli in the list.
|
||
|
||
**Parameters**
|
||
|
||
* **other** ([*PauliList*](qiskit.quantum_info.PauliList "qiskit.quantum_info.PauliList")) – another PauliList.
|
||
* **qargs** (*None or list*) – qubits to apply dot product on (Default: None).
|
||
* **inplace** (*bool*) – If True update in-place (default: False).
|
||
|
||
**Returns**
|
||
|
||
the list of composed Paulis.
|
||
|
||
**Return type**
|
||
|
||
[PauliList](qiskit.quantum_info.PauliList "qiskit.quantum_info.PauliList")
|
||
|
||
**Raises**
|
||
|
||
**QiskitError** – if other cannot be converted to a PauliList, does not have either 1 or the same number of Paulis as the current list, or has the wrong number of qubits for the specified qargs.
|
||
</Function>
|
||
|
||
<span id="qiskit-quantum-info-paulilist-equiv" />
|
||
|
||
### equiv
|
||
|
||
<Function id="qiskit.quantum_info.PauliList.equiv" signature="PauliList.equiv(other)">
|
||
Entrywise comparison of Pauli equivalence up to global phase.
|
||
|
||
**Parameters**
|
||
|
||
**other** ([*PauliList*](qiskit.quantum_info.PauliList "qiskit.quantum_info.PauliList") *or*[*Pauli*](qiskit.quantum_info.Pauli "qiskit.quantum_info.Pauli")) – a comparison object.
|
||
|
||
**Returns**
|
||
|
||
**An array of True or False for entrywise equivalence**
|
||
|
||
of the current table.
|
||
|
||
**Return type**
|
||
|
||
np.ndarray
|
||
</Function>
|
||
|
||
<span id="qiskit-quantum-info-paulilist-evolve" />
|
||
|
||
### evolve
|
||
|
||
<Function id="qiskit.quantum_info.PauliList.evolve" signature="PauliList.evolve(other, qargs=None)">
|
||
Evolve the Pauli by a Clifford.
|
||
|
||
This returns the Pauli $P^\prime = C.P.C^\dagger$.
|
||
|
||
**Parameters**
|
||
|
||
* **other** ([*Pauli*](qiskit.quantum_info.Pauli "qiskit.quantum_info.Pauli") *or*[*Clifford*](qiskit.quantum_info.Clifford "qiskit.quantum_info.Clifford") *or*[*QuantumCircuit*](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")) – The Clifford operator to evolve by.
|
||
* **qargs** (*list*) – a list of qubits to apply the Clifford to.
|
||
|
||
**Returns**
|
||
|
||
the Pauli $C.P.C^\dagger$.
|
||
|
||
**Return type**
|
||
|
||
[Pauli](qiskit.quantum_info.Pauli "qiskit.quantum_info.Pauli")
|
||
|
||
**Raises**
|
||
|
||
**QiskitError** – if the Clifford number of qubits and qargs don’t match.
|
||
</Function>
|
||
|
||
<span id="qiskit-quantum-info-paulilist-expand" />
|
||
|
||
### expand
|
||
|
||
<Function id="qiskit.quantum_info.PauliList.expand" signature="PauliList.expand(other)">
|
||
Return the expand product of each Pauli in the list.
|
||
|
||
**Parameters**
|
||
|
||
**other** ([*PauliList*](qiskit.quantum_info.PauliList "qiskit.quantum_info.PauliList")) – another PauliList.
|
||
|
||
**Returns**
|
||
|
||
the list of tensor product Paulis.
|
||
|
||
**Return type**
|
||
|
||
[PauliList](qiskit.quantum_info.PauliList "qiskit.quantum_info.PauliList")
|
||
|
||
**Raises**
|
||
|
||
**QiskitError** – if other cannot be converted to a PauliList, does not have either 1 or the same number of Paulis as the current list.
|
||
</Function>
|
||
|
||
<span id="qiskit-quantum-info-paulilist-from-symplectic" />
|
||
|
||
### from\_symplectic
|
||
|
||
<Function id="qiskit.quantum_info.PauliList.from_symplectic" signature="PauliList.from_symplectic(z, x, phase=0)" modifiers="classmethod">
|
||
Construct a PauliList from a symplectic data.
|
||
|
||
**Parameters**
|
||
|
||
* **z** (*np.ndarray*) – 2D boolean Numpy array.
|
||
* **x** (*np.ndarray*) – 2D boolean Numpy array.
|
||
* **phase** (*np.ndarray or None*) – Optional, 1D integer array from Z\_4.
|
||
|
||
**Returns**
|
||
|
||
the constructed PauliList.
|
||
|
||
**Return type**
|
||
|
||
[PauliList](qiskit.quantum_info.PauliList "qiskit.quantum_info.PauliList")
|
||
</Function>
|
||
|
||
<span id="qiskit-quantum-info-paulilist-input-dims" />
|
||
|
||
### input\_dims
|
||
|
||
<Function id="qiskit.quantum_info.PauliList.input_dims" signature="PauliList.input_dims(qargs=None)">
|
||
Return tuple of input dimension for specified subsystems.
|
||
</Function>
|
||
|
||
<span id="qiskit-quantum-info-paulilist-insert" />
|
||
|
||
### insert
|
||
|
||
<Function id="qiskit.quantum_info.PauliList.insert" signature="PauliList.insert(ind, value, qubit=False)">
|
||
Insert Pauli’s into the table.
|
||
|
||
When inserting qubits the qubit index is the same as the column index of the underlying `X` and `Z` arrays.
|
||
|
||
**Parameters**
|
||
|
||
* **ind** (*int*) – index to insert at.
|
||
* **value** ([*PauliList*](qiskit.quantum_info.PauliList "qiskit.quantum_info.PauliList")) – values to insert.
|
||
* **qubit** (*bool*) – if True delete qubit columns, otherwise delete Pauli rows (Default: False).
|
||
|
||
**Returns**
|
||
|
||
the resulting table with the entries inserted.
|
||
|
||
**Return type**
|
||
|
||
[PauliList](qiskit.quantum_info.PauliList "qiskit.quantum_info.PauliList")
|
||
|
||
**Raises**
|
||
|
||
**QiskitError** – if the insertion index is invalid.
|
||
</Function>
|
||
|
||
<span id="qiskit-quantum-info-paulilist-inverse" />
|
||
|
||
### inverse
|
||
|
||
<Function id="qiskit.quantum_info.PauliList.inverse" signature="PauliList.inverse()">
|
||
Return the inverse of each Pauli in the list.
|
||
</Function>
|
||
|
||
<span id="qiskit-quantum-info-paulilist-label-iter" />
|
||
|
||
### label\_iter
|
||
|
||
<Function id="qiskit.quantum_info.PauliList.label_iter" signature="PauliList.label_iter()">
|
||
Return a label representation iterator.
|
||
|
||
This is a lazy iterator that converts each row into the string label only as it is used. To convert the entire table to labels use the [`to_labels()`](qiskit.quantum_info.PauliList#to_labels "qiskit.quantum_info.PauliList.to_labels") method.
|
||
|
||
**Returns**
|
||
|
||
label iterator object for the PauliList.
|
||
|
||
**Return type**
|
||
|
||
LabelIterator
|
||
</Function>
|
||
|
||
<span id="qiskit-quantum-info-paulilist-matrix-iter" />
|
||
|
||
### matrix\_iter
|
||
|
||
<Function id="qiskit.quantum_info.PauliList.matrix_iter" signature="PauliList.matrix_iter(sparse=False)">
|
||
Return a matrix representation iterator.
|
||
|
||
This is a lazy iterator that converts each row into the Pauli matrix representation only as it is used. To convert the entire table to matrices use the [`to_matrix()`](qiskit.quantum_info.PauliList#to_matrix "qiskit.quantum_info.PauliList.to_matrix") method.
|
||
|
||
**Parameters**
|
||
|
||
**sparse** (*bool*) – optionally return sparse CSR matrices if True, otherwise return Numpy array matrices (Default: False)
|
||
|
||
**Returns**
|
||
|
||
matrix iterator object for the PauliList.
|
||
|
||
**Return type**
|
||
|
||
MatrixIterator
|
||
</Function>
|
||
|
||
<span id="qiskit-quantum-info-paulilist-output-dims" />
|
||
|
||
### output\_dims
|
||
|
||
<Function id="qiskit.quantum_info.PauliList.output_dims" signature="PauliList.output_dims(qargs=None)">
|
||
Return tuple of output dimension for specified subsystems.
|
||
</Function>
|
||
|
||
<span id="qiskit-quantum-info-paulilist-power" />
|
||
|
||
### power
|
||
|
||
<Function id="qiskit.quantum_info.PauliList.power" signature="PauliList.power(n)">
|
||
Return the compose of a operator with itself n times.
|
||
|
||
**Parameters**
|
||
|
||
**n** (*int*) – the number of times to compose with self (n>0).
|
||
|
||
**Returns**
|
||
|
||
the n-times composed operator.
|
||
|
||
**Return type**
|
||
|
||
[Pauli](qiskit.quantum_info.Pauli "qiskit.quantum_info.Pauli")
|
||
|
||
**Raises**
|
||
|
||
**QiskitError** – if the input and output dimensions of the operator are not equal, or the power is not a positive integer.
|
||
</Function>
|
||
|
||
<span id="qiskit-quantum-info-paulilist-reshape" />
|
||
|
||
### reshape
|
||
|
||
<Function id="qiskit.quantum_info.PauliList.reshape" signature="PauliList.reshape(input_dims=None, output_dims=None, num_qubits=None)">
|
||
Return a shallow copy with reshaped input and output subsystem dimensions.
|
||
|
||
**Parameters**
|
||
|
||
* **input\_dims** (*None or tuple*) – new subsystem input dimensions. If None the original input dims will be preserved \[Default: None].
|
||
* **output\_dims** (*None or tuple*) – new subsystem output dimensions. If None the original output dims will be preserved \[Default: None].
|
||
* **num\_qubits** (*None or int*) – reshape to an N-qubit operator \[Default: None].
|
||
|
||
**Returns**
|
||
|
||
returns self with reshaped input and output dimensions.
|
||
|
||
**Return type**
|
||
|
||
BaseOperator
|
||
|
||
**Raises**
|
||
|
||
**QiskitError** – if combined size of all subsystem input dimension or subsystem output dimensions is not constant.
|
||
</Function>
|
||
|
||
<span id="qiskit-quantum-info-paulilist-sort" />
|
||
|
||
### sort
|
||
|
||
<Function id="qiskit.quantum_info.PauliList.sort" signature="PauliList.sort(weight=False, phase=False)">
|
||
Sort the rows of the table.
|
||
|
||
The default sort method is lexicographic sorting by qubit number. By using the weight kwarg the output can additionally be sorted by the number of non-identity terms in the Pauli, where the set of all Pauli’s of a given weight are still ordered lexicographically.
|
||
|
||
**Example**
|
||
|
||
Consider sorting all a random ordering of all 2-qubit Paulis
|
||
|
||
```python
|
||
from numpy.random import shuffle
|
||
from qiskit.quantum_info.operators import PauliList
|
||
|
||
# 2-qubit labels
|
||
labels = ['II', 'IX', 'IY', 'IZ', 'XI', 'XX', 'XY', 'XZ',
|
||
'YI', 'YX', 'YY', 'YZ', 'ZI', 'ZX', 'ZY', 'ZZ']
|
||
# Shuffle Labels
|
||
shuffle(labels)
|
||
pt = PauliList(labels)
|
||
print('Initial Ordering')
|
||
print(pt)
|
||
|
||
# Lexicographic Ordering
|
||
srt = pt.sort()
|
||
print('Lexicographically sorted')
|
||
print(srt)
|
||
|
||
# Weight Ordering
|
||
srt = pt.sort(weight=True)
|
||
print('Weight sorted')
|
||
print(srt)
|
||
```
|
||
|
||
```
|
||
Initial Ordering
|
||
['XI', 'XY', 'IZ', 'ZI', 'ZX', 'IY', 'YY', 'IX', 'ZY', 'XZ', 'ZZ', 'II',
|
||
'YX', 'XX', 'YI', 'YZ']
|
||
Lexicographically sorted
|
||
['II', 'IX', 'IY', 'IZ', 'XI', 'XX', 'XY', 'XZ', 'YI', 'YX', 'YY', 'YZ',
|
||
'ZI', 'ZX', 'ZY', 'ZZ']
|
||
Weight sorted
|
||
['II', 'IX', 'IY', 'IZ', 'XI', 'YI', 'ZI', 'XX', 'XY', 'XZ', 'YX', 'YY',
|
||
'YZ', 'ZX', 'ZY', 'ZZ']
|
||
```
|
||
|
||
**Parameters**
|
||
|
||
* **weight** (*bool*) – optionally sort by weight if True (Default: False).
|
||
* **phase** (*bool*) – Optionally sort by phase before weight or order (Default: False).
|
||
|
||
**Returns**
|
||
|
||
a sorted copy of the original table.
|
||
|
||
**Return type**
|
||
|
||
[PauliList](qiskit.quantum_info.PauliList "qiskit.quantum_info.PauliList")
|
||
</Function>
|
||
|
||
<span id="qiskit-quantum-info-paulilist-tensor" />
|
||
|
||
### tensor
|
||
|
||
<Function id="qiskit.quantum_info.PauliList.tensor" signature="PauliList.tensor(other)">
|
||
Return the tensor product with each Pauli in the list.
|
||
|
||
**Parameters**
|
||
|
||
**other** ([*PauliList*](qiskit.quantum_info.PauliList "qiskit.quantum_info.PauliList")) – another PauliList.
|
||
|
||
**Returns**
|
||
|
||
the list of tensor product Paulis.
|
||
|
||
**Return type**
|
||
|
||
[PauliList](qiskit.quantum_info.PauliList "qiskit.quantum_info.PauliList")
|
||
|
||
**Raises**
|
||
|
||
**QiskitError** – if other cannot be converted to a PauliList, does not have either 1 or the same number of Paulis as the current list.
|
||
</Function>
|
||
|
||
<span id="qiskit-quantum-info-paulilist-to-labels" />
|
||
|
||
### to\_labels
|
||
|
||
<Function id="qiskit.quantum_info.PauliList.to_labels" signature="PauliList.to_labels(array=False)">
|
||
Convert a PauliList to a list Pauli string labels.
|
||
|
||
For large PauliLists converting using the `array=True` kwarg will be more efficient since it allocates memory for the full Numpy array of labels in advance.
|
||
|
||
| Label | Symplectic | Matrix |
|
||
| ----- | ---------- | ----------------------------------------------- |
|
||
| `"I"` | $[0, 0]$ | $\begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix}$ |
|
||
| `"X"` | $[1, 0]$ | $\begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}$ |
|
||
| `"Y"` | $[1, 1]$ | $\begin{bmatrix} 0 & -i \\ i & 0 \end{bmatrix}$ |
|
||
| `"Z"` | $[0, 1]$ | $\begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix}$ |
|
||
|
||
**Parameters**
|
||
|
||
**array** (*bool*) – return a Numpy array if True, otherwise return a list (Default: False).
|
||
|
||
**Returns**
|
||
|
||
The rows of the PauliList in label form.
|
||
|
||
**Return type**
|
||
|
||
list or array
|
||
</Function>
|
||
|
||
<span id="qiskit-quantum-info-paulilist-to-matrix" />
|
||
|
||
### to\_matrix
|
||
|
||
<Function id="qiskit.quantum_info.PauliList.to_matrix" signature="PauliList.to_matrix(sparse=False, array=False)">
|
||
Convert to a list or array of Pauli matrices.
|
||
|
||
For large PauliLists converting using the `array=True` kwarg will be more efficient since it allocates memory a full rank-3 Numpy array of matrices in advance.
|
||
|
||
| Label | Symplectic | Matrix |
|
||
| ----- | ---------- | ----------------------------------------------- |
|
||
| `"I"` | $[0, 0]$ | $\begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix}$ |
|
||
| `"X"` | $[1, 0]$ | $\begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}$ |
|
||
| `"Y"` | $[1, 1]$ | $\begin{bmatrix} 0 & -i \\ i & 0 \end{bmatrix}$ |
|
||
| `"Z"` | $[0, 1]$ | $\begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix}$ |
|
||
|
||
**Parameters**
|
||
|
||
* **sparse** (*bool*) – if True return sparse CSR matrices, otherwise return dense Numpy arrays (Default: False).
|
||
* **array** (*bool*) – return as rank-3 numpy array if True, otherwise return a list of Numpy arrays (Default: False).
|
||
|
||
**Returns**
|
||
|
||
A list of dense Pauli matrices if array=False and sparse=False. list: A list of sparse Pauli matrices if array=False and sparse=True. array: A dense rank-3 array of Pauli matrices if array=True.
|
||
|
||
**Return type**
|
||
|
||
list
|
||
</Function>
|
||
|
||
<span id="qiskit-quantum-info-paulilist-transpose" />
|
||
|
||
### transpose
|
||
|
||
<Function id="qiskit.quantum_info.PauliList.transpose" signature="PauliList.transpose()">
|
||
Return the transpose of each Pauli in the list.
|
||
</Function>
|
||
|
||
<span id="qiskit-quantum-info-paulilist-unique" />
|
||
|
||
### unique
|
||
|
||
<Function id="qiskit.quantum_info.PauliList.unique" signature="PauliList.unique(return_index=False, return_counts=False)">
|
||
Return unique Paulis from the table.
|
||
|
||
**Example**
|
||
|
||
```python
|
||
from qiskit.quantum_info.operators import PauliList
|
||
|
||
pt = PauliList(['X', 'Y', '-X', 'I', 'I', 'Z', 'X', 'iZ'])
|
||
unique = pt.unique()
|
||
print(unique)
|
||
```
|
||
|
||
```
|
||
['X', 'Y', '-X', 'I', 'Z', 'iZ']
|
||
```
|
||
|
||
**Parameters**
|
||
|
||
* **return\_index** (*bool*) – If True, also return the indices that result in the unique array. (Default: False)
|
||
* **return\_counts** (*bool*) – If True, also return the number of times each unique item appears in the table.
|
||
|
||
**Returns**
|
||
|
||
**unique**
|
||
|
||
the table of the unique rows.
|
||
|
||
**unique\_indices: np.ndarray, optional**
|
||
|
||
The indices of the first occurrences of the unique values in the original array. Only provided if `return_index` is True.
|
||
|
||
**unique\_counts: np.array, optional**
|
||
|
||
The number of times each of the unique values comes up in the original array. Only provided if `return_counts` is True.
|
||
|
||
**Return type**
|
||
|
||
[PauliList](qiskit.quantum_info.PauliList "qiskit.quantum_info.PauliList")
|
||
</Function>
|
||
|
||
## Attributes
|
||
|
||
### dim
|
||
|
||
<Attribute id="qiskit.quantum_info.PauliList.dim">
|
||
Return tuple (input\_shape, output\_shape).
|
||
</Attribute>
|
||
|
||
### num\_qubits
|
||
|
||
<Attribute id="qiskit.quantum_info.PauliList.num_qubits">
|
||
Return the number of qubits if a N-qubit operator or None otherwise.
|
||
</Attribute>
|
||
|
||
### phase
|
||
|
||
<Attribute id="qiskit.quantum_info.PauliList.phase">
|
||
Return the phase exponent of the PauliList.
|
||
</Attribute>
|
||
|
||
### qargs
|
||
|
||
<Attribute id="qiskit.quantum_info.PauliList.qargs">
|
||
Return the qargs for the operator.
|
||
</Attribute>
|
||
|
||
### settings
|
||
|
||
<Attribute id="qiskit.quantum_info.PauliList.settings">
|
||
Return operator settings.
|
||
</Attribute>
|
||
|
||
### shape
|
||
|
||
<Attribute id="qiskit.quantum_info.PauliList.shape">
|
||
The full shape of the `array()`
|
||
</Attribute>
|
||
|
||
### size
|
||
|
||
<Attribute id="qiskit.quantum_info.PauliList.size">
|
||
The number of Pauli rows in the table.
|
||
</Attribute>
|
||
|
||
### x
|
||
|
||
<Attribute id="qiskit.quantum_info.PauliList.x">
|
||
The x array for the symplectic representation.
|
||
</Attribute>
|
||
|
||
### z
|
||
|
||
<Attribute id="qiskit.quantum_info.PauliList.z">
|
||
The z array for the symplectic representation.
|
||
</Attribute>
|
||
</Class>
|
||
|