qiskit-documentation/docs/api/qiskit/0.41/qiskit_aer.noise.QuantumErr...

339 lines
11 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: QuantumError
description: API reference for qiskit_aer.noise.QuantumError
in_page_toc_min_heading_level: 1
python_api_type: class
python_api_name: qiskit_aer.noise.QuantumError
---
# QuantumError
<Class id="qiskit_aer.noise.QuantumError" isDedicatedPage={true} github="https://github.com/qiskit/qiskit-aer/tree/stable/0.11/qiskit_aer/noise/errors/quantum_error.py" signature="QuantumError(noise_ops, number_of_qubits=None, standard_gates=None, atol=None)" modifiers="class">
Bases: `qiskit.quantum_info.operators.base_operator.BaseOperator`, `qiskit.quantum_info.operators.mixins.tolerances.TolerancesMixin`
Quantum error class for Qiskit Aer noise model
<Admonition title="Warning" type="caution">
The init interface for this class is not finalized and may change in future releases. For maximum backwards compatibility use the QuantumError generating functions in the noise.errors module.
</Admonition>
Create a quantum error for a noise model.
Noise ops may either be specified as a `QuantumChannel` for a general CPTP map, or as a list of `(circuit, p)` pairs where `circuit` is a circuit-like object for the noise, and `p` is the probability of the noise event. Any type of input will be converted to the probabilistic mixture of circuit format.
**Example**
An example noise\_ops for a bit-flip error with error probability `p = 0.1` is:
```python
noise_ops = [(IGate(), 0.9),
(XGate(), 0.1)]
```
or specifying explicit qubit arguments,
```python
noise_ops = [((IGate(), [0]), 0.9),
((XGate(), [0]), 0.1)]
```
The same error represented as a Kraus channel can be input as:
```python
noise_ops = Kraus([np.sqrt(0.9) * np.array([[1, 0], [0, 1]]),
np.sqrt(0.1) * np.array([[0, 1], [1, 0]])])
```
**Parameters**
* **noise\_ops** (*QuantumChannel or Iterable*) Either a quantum channel or a list of `(circuit, p)` pairs, which represents a quantum error, where `circuit` is a circuit-like object for the noise, and `p` is the probability of the noise event. Circuit-like types include `QuantumCircuit`, `(Instruction, qargs)` and a list of `(Instruction, qargs)`. Note that `qargs` should be a list of integers and can be omitted (default qubits are used in that case). See also examples above.
* **number\_of\_qubits** (*int*) \[DEPRECATED] specify the number of qubits for the error. If None this will be determined automatically (default None).
* **standard\_gates** (*bool*) \[DEPRECATED] Check if input matrices are standard gates.
* **atol** (*double*) \[DEPRECATED] Threshold for testing if probabilities are equal to 0 or 1 (Default: `QuantumError.atol`).
**Raises**
**NoiseError** If input noise\_ops is invalid, e.g. its not a CPTP map.
## Methods
### compose
<Function id="qiskit_aer.noise.QuantumError.compose" signature="QuantumError.compose(other, qargs=None, front=False)">
Return the operator composition with another CLASS.
**Parameters**
* **other** (*CLASS*) a CLASS object.
* **qargs** (*list or None*) Optional, a list of subsystem positions to apply other on. If None apply on all subsystems (default: None).
* **front** (*bool*) If True compose using right operator multiplication, instead of left multiplication \[default: False].
**Returns**
The composed CLASS.
**Return type**
CLASS
**Raises**
**QiskitError** if other cannot be converted to an operator, or has incompatible dimensions for specified subsystems.
<Admonition title="Note" type="note">
Composition (`&`) by default is defined as left matrix multiplication for matrix operators, while `@` (equivalent to [`dot()`](qiskit_aer.noise.QuantumError#dot "qiskit_aer.noise.QuantumError.dot")) is defined as right matrix multiplication. That is that `A & B == A.compose(B)` is equivalent to `B @ A == B.dot(A)` when `A` and `B` are of the same type.
Setting the `front=True` kwarg changes this to right matrix multiplication and is equivalent to the [`dot()`](qiskit_aer.noise.QuantumError#dot "qiskit_aer.noise.QuantumError.dot") method `A.dot(B) == A.compose(B, front=True)`.
</Admonition>
</Function>
### copy
<Function id="qiskit_aer.noise.QuantumError.copy" signature="QuantumError.copy()">
Make a copy of current QuantumError.
</Function>
### dot
<Function id="qiskit_aer.noise.QuantumError.dot" signature="QuantumError.dot(other, qargs=None)">
Return the right multiplied operator self \* other.
**Parameters**
* **other** ([*Operator*](qiskit.quantum_info.Operator "qiskit.quantum_info.Operator")) an operator object.
* **qargs** (*list or None*) Optional, a list of subsystem positions to apply other on. If None apply on all subsystems (default: None).
**Returns**
The right matrix multiplied Operator.
**Return type**
[Operator](qiskit.quantum_info.Operator "qiskit.quantum_info.Operator")
<Admonition title="Note" type="note">
The dot product can be obtained using the `@` binary operator. Hence `a.dot(b)` is equivalent to `a @ b`.
</Admonition>
</Function>
### error\_term
<Function id="qiskit_aer.noise.QuantumError.error_term" signature="QuantumError.error_term(position)">
Return a single term from the error.
**Parameters**
**position** (*int*) the position of the error term.
**Returns**
A pair (circuit, p) for error term at position \< size where p is the probability of the error term, and circuit is the list of qobj instructions for the error term.
**Return type**
tuple
**Raises**
* **NoiseError** If the position is greater than the size of
* **the quantum error.**
</Function>
### expand
<Function id="qiskit_aer.noise.QuantumError.expand" signature="QuantumError.expand(other)">
Return the reverse-order tensor product with another CLASS.
**Parameters**
**other** (*CLASS*) a CLASS object.
**Returns**
**the tensor product $b \otimes a$, where $a$**
is the current CLASS, and $b$ is the other CLASS.
**Return type**
CLASS
</Function>
### ideal
<Function id="qiskit_aer.noise.QuantumError.ideal" signature="QuantumError.ideal()">
Return True if this error object is composed only of identity operations. Note that the identity check is best effort and up to global phase.
</Function>
### input\_dims
<Function id="qiskit_aer.noise.QuantumError.input_dims" signature="QuantumError.input_dims(qargs=None)">
Return tuple of input dimension for specified subsystems.
</Function>
### output\_dims
<Function id="qiskit_aer.noise.QuantumError.output_dims" signature="QuantumError.output_dims(qargs=None)">
Return tuple of output dimension for specified subsystems.
</Function>
### power
<Function id="qiskit_aer.noise.QuantumError.power" signature="QuantumError.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>
### reshape
<Function id="qiskit_aer.noise.QuantumError.reshape" signature="QuantumError.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>
### set\_atol
<Function id="qiskit_aer.noise.QuantumError.set_atol" signature="QuantumError.set_atol(value)" modifiers="classmethod">
Set the class default absolute tolerance parameter for float comparisons.
</Function>
### set\_rtol
<Function id="qiskit_aer.noise.QuantumError.set_rtol" signature="QuantumError.set_rtol(value)" modifiers="classmethod">
Set the class default relative tolerance parameter for float comparisons.
</Function>
### tensor
<Function id="qiskit_aer.noise.QuantumError.tensor" signature="QuantumError.tensor(other)">
Return the tensor product with another CLASS.
**Parameters**
**other** (*CLASS*) a CLASS object.
**Returns**
**the tensor product $a \otimes b$, where $a$**
is the current CLASS, and $b$ is the other CLASS.
**Return type**
CLASS
<Admonition title="Note" type="note">
The tensor product can be obtained using the `^` binary operator. Hence `a.tensor(b)` is equivalent to `a ^ b`.
</Admonition>
</Function>
### to\_dict
<Function id="qiskit_aer.noise.QuantumError.to_dict" signature="QuantumError.to_dict()">
Return the current error as a dictionary.
</Function>
### to\_instruction
<Function id="qiskit_aer.noise.QuantumError.to_instruction" signature="QuantumError.to_instruction()">
Convert the QuantumError to a circuit Instruction.
</Function>
### to\_quantumchannel
<Function id="qiskit_aer.noise.QuantumError.to_quantumchannel" signature="QuantumError.to_quantumchannel()">
Convert the QuantumError to a SuperOp quantum channel. Required to enable SuperOp(QuantumError).
</Function>
## Attributes
### atol
<Attribute id="qiskit_aer.noise.QuantumError.atol" attributeValue="1e-08" />
### circuits
<Attribute id="qiskit_aer.noise.QuantumError.circuits">
Return the list of error circuits.
</Attribute>
### dim
<Attribute id="qiskit_aer.noise.QuantumError.dim">
Return tuple (input\_shape, output\_shape).
</Attribute>
### id
<Attribute id="qiskit_aer.noise.QuantumError.id">
Return unique ID string for error
</Attribute>
### num\_qubits
<Attribute id="qiskit_aer.noise.QuantumError.num_qubits">
Return the number of qubits if a N-qubit operator or None otherwise.
</Attribute>
### number\_of\_qubits
<Attribute id="qiskit_aer.noise.QuantumError.number_of_qubits">
Return the number of qubits for the error.
</Attribute>
### probabilities
<Attribute id="qiskit_aer.noise.QuantumError.probabilities">
Return the list of error probabilities.
</Attribute>
### qargs
<Attribute id="qiskit_aer.noise.QuantumError.qargs">
Return the qargs for the operator.
</Attribute>
### rtol
<Attribute id="qiskit_aer.noise.QuantumError.rtol" attributeValue="1e-05" />
### size
<Attribute id="qiskit_aer.noise.QuantumError.size">
Return the number of error circuit.
</Attribute>
</Class>