Generate Qiskit 1.2.4 (#2068)

The release notes rendered well locally with `./start --apis`.
This commit is contained in:
Eric Arellano 2024-10-04 07:50:28 -04:00 committed by GitHub
parent a557167fcd
commit f0c693a98a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
49 changed files with 1607 additions and 160 deletions

View File

@ -1,4 +1,4 @@
{
"name": "qiskit",
"version": "1.2.2"
"version": "1.2.4"
}

View File

@ -400,7 +400,7 @@ Most operations, including all operations on physical circuits, are instances of
| ---------------------------------------------------------------------------------------------------------------- | ---------------------------- |
| [`Instruction`](qiskit.circuit.Instruction "qiskit.circuit.Instruction")(name, num\_qubits, num\_clbits, params) | Generic quantum instruction. |
[`Instruction`](qiskit.circuit.Instruction "qiskit.circuit.Instruction")s can be near arbitrary, provided they only act on [`Qubit`](#qiskit.circuit.Qubit "qiskit.circuit.Qubit")s and [`Clbit`](#qiskit.circuit.Clbit "qiskit.circuit.Clbit")s, and are parametrized by their [`params`](qiskit.circuit.Instruction#params "qiskit.circuit.Instruction.params"); they should not attempt to “close over” outer circuit registers, or use hidden parameters inside themselves. [`Instruction`](qiskit.circuit.Instruction "qiskit.circuit.Instruction")s can be related to other circuits to provide a decompositions by using their [`Instruction.definition`](qiskit.circuit.Instruction#definition "qiskit.circuit.Instruction.definition") attribute, which provides a local, one-off decomposition. This can be in whatever basis set of operations is most convenient to you, as long as the definitions of all contained gates have some topological order; that is, you cannot use a gate in a definition it its own definition depends on the parent. If the [`Instruction`](qiskit.circuit.Instruction "qiskit.circuit.Instruction") should be considered entirely opaque to optimizers, its [`definition`](qiskit.circuit.Instruction#definition "qiskit.circuit.Instruction.definition") can be `None`. See [Creating custom instructions](#circuit-custom-gates) for more detail.
[`Instruction`](qiskit.circuit.Instruction "qiskit.circuit.Instruction")s can be near arbitrary, provided they only act on [`Qubit`](#qiskit.circuit.Qubit "qiskit.circuit.Qubit")s and [`Clbit`](#qiskit.circuit.Clbit "qiskit.circuit.Clbit")s, and are parametrized by their [`params`](qiskit.circuit.Instruction#params "qiskit.circuit.Instruction.params"); they should not attempt to “close over” outer circuit registers, or use hidden parameters inside themselves. [`Instruction`](qiskit.circuit.Instruction "qiskit.circuit.Instruction")s can be related to other circuits to provide a decompositions by using their [`Instruction.definition`](qiskit.circuit.Instruction#definition "qiskit.circuit.Instruction.definition") attribute, which provides a local, one-off decomposition. This can be in whatever basis set of operations is most convenient to you, as long as the definitions of all contained gates have some topological order; that is, you cannot use a gate in a definition if its own definition depends on the parent. If the [`Instruction`](qiskit.circuit.Instruction "qiskit.circuit.Instruction") should be considered entirely opaque to optimizers, its [`definition`](qiskit.circuit.Instruction#definition "qiskit.circuit.Instruction.definition") can be `None`. See [Creating custom instructions](#circuit-custom-gates) for more detail.
The [`params`](qiskit.circuit.Instruction#params "qiskit.circuit.Instruction.params") of an instruction can technically be arbitrary, but in general you should attempt to stick to parametrizations in terms of real numbers, wherever possible. Qiskit itself breaks this rule in many places, and you will find all sorts of unusual types in [`Instruction.params`](qiskit.circuit.Instruction#params "qiskit.circuit.Instruction.params") fields, but these are an annoying source of bugs because they often imply the need for type-aware special casing. If your instruction is parametrized in terms of angles, you will be able to reliably use [compile-time parametrization in it](#circuit-compile-time-parameters), and it will integrate well with [`QuantumCircuit.assign_parameters()`](qiskit.circuit.QuantumCircuit#assign_parameters "qiskit.circuit.QuantumCircuit.assign_parameters").

View File

@ -98,7 +98,17 @@ python_api_name: qiskit.circuit.library.EfficientSU2
### data
<Attribute id="qiskit.circuit.library.EfficientSU2.data" />
<Attribute id="qiskit.circuit.library.EfficientSU2.data">
The circuit data (instructions and context).
**Returns**
a list-like object containing the [`CircuitInstruction`](qiskit.circuit.CircuitInstruction "qiskit.circuit.CircuitInstruction")s for each instruction.
**Return type**
QuantumCircuitData
</Attribute>
### entanglement
@ -222,7 +232,9 @@ python_api_name: qiskit.circuit.library.EfficientSU2
### num\_parameters
<Attribute id="qiskit.circuit.library.EfficientSU2.num_parameters" />
<Attribute id="qiskit.circuit.library.EfficientSU2.num_parameters">
The number of parameter objects in the circuit.
</Attribute>
### num\_parameters\_settable
@ -312,7 +324,61 @@ python_api_name: qiskit.circuit.library.EfficientSU2
### parameters
<Attribute id="qiskit.circuit.library.EfficientSU2.parameters" />
<Attribute id="qiskit.circuit.library.EfficientSU2.parameters">
The parameters defined in the circuit.
This attribute returns the [`Parameter`](qiskit.circuit.Parameter "qiskit.circuit.Parameter") objects in the circuit sorted alphabetically. Note that parameters instantiated with a [`ParameterVector`](qiskit.circuit.ParameterVector "qiskit.circuit.ParameterVector") are still sorted numerically.
**Examples**
The snippet below shows that insertion order of parameters does not matter.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter
>>> a, b, elephant = Parameter("a"), Parameter("b"), Parameter("elephant")
>>> circuit = QuantumCircuit(1)
>>> circuit.rx(b, 0)
>>> circuit.rz(elephant, 0)
>>> circuit.ry(a, 0)
>>> circuit.parameters # sorted alphabetically!
ParameterView([Parameter(a), Parameter(b), Parameter(elephant)])
```
Bear in mind that alphabetical sorting might be unintuitive when it comes to numbers. The literal “10” comes before “2” in strict alphabetical sorting.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter
>>> angles = [Parameter("angle_1"), Parameter("angle_2"), Parameter("angle_10")]
>>> circuit = QuantumCircuit(1)
>>> circuit.u(*angles, 0)
>>> circuit.draw()
┌─────────────────────────────┐
q: ┤ U(angle_1,angle_2,angle_10) ├
└─────────────────────────────┘
>>> circuit.parameters
ParameterView([Parameter(angle_1), Parameter(angle_10), Parameter(angle_2)])
```
To respect numerical sorting, a [`ParameterVector`](qiskit.circuit.ParameterVector "qiskit.circuit.ParameterVector") can be used.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter, ParameterVector
>>> x = ParameterVector("x", 12)
>>> circuit = QuantumCircuit(1)
>>> for x_i in x:
... circuit.rx(x_i, 0)
>>> circuit.parameters
ParameterView([
ParameterVectorElement(x[0]), ParameterVectorElement(x[1]),
ParameterVectorElement(x[2]), ParameterVectorElement(x[3]),
..., ParameterVectorElement(x[11])
])
```
**Returns**
The sorted [`Parameter`](qiskit.circuit.Parameter "qiskit.circuit.Parameter") objects in the circuit.
</Attribute>
### preferred\_init\_points

View File

@ -48,7 +48,17 @@ python_api_name: qiskit.circuit.library.EvolvedOperatorAnsatz
### data
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.data" />
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.data">
The circuit data (instructions and context).
**Returns**
a list-like object containing the [`CircuitInstruction`](qiskit.circuit.CircuitInstruction "qiskit.circuit.CircuitInstruction")s for each instruction.
**Return type**
QuantumCircuitData
</Attribute>
### entanglement
@ -186,7 +196,9 @@ python_api_name: qiskit.circuit.library.EvolvedOperatorAnsatz
### num\_parameters
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.num_parameters" />
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.num_parameters">
The number of parameter objects in the circuit.
</Attribute>
### num\_parameters\_settable
@ -290,7 +302,61 @@ python_api_name: qiskit.circuit.library.EvolvedOperatorAnsatz
### parameters
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.parameters" />
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.parameters">
The parameters defined in the circuit.
This attribute returns the [`Parameter`](qiskit.circuit.Parameter "qiskit.circuit.Parameter") objects in the circuit sorted alphabetically. Note that parameters instantiated with a [`ParameterVector`](qiskit.circuit.ParameterVector "qiskit.circuit.ParameterVector") are still sorted numerically.
**Examples**
The snippet below shows that insertion order of parameters does not matter.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter
>>> a, b, elephant = Parameter("a"), Parameter("b"), Parameter("elephant")
>>> circuit = QuantumCircuit(1)
>>> circuit.rx(b, 0)
>>> circuit.rz(elephant, 0)
>>> circuit.ry(a, 0)
>>> circuit.parameters # sorted alphabetically!
ParameterView([Parameter(a), Parameter(b), Parameter(elephant)])
```
Bear in mind that alphabetical sorting might be unintuitive when it comes to numbers. The literal “10” comes before “2” in strict alphabetical sorting.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter
>>> angles = [Parameter("angle_1"), Parameter("angle_2"), Parameter("angle_10")]
>>> circuit = QuantumCircuit(1)
>>> circuit.u(*angles, 0)
>>> circuit.draw()
┌─────────────────────────────┐
q: ┤ U(angle_1,angle_2,angle_10) ├
└─────────────────────────────┘
>>> circuit.parameters
ParameterView([Parameter(angle_1), Parameter(angle_10), Parameter(angle_2)])
```
To respect numerical sorting, a [`ParameterVector`](qiskit.circuit.ParameterVector "qiskit.circuit.ParameterVector") can be used.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter, ParameterVector
>>> x = ParameterVector("x", 12)
>>> circuit = QuantumCircuit(1)
>>> for x_i in x:
... circuit.rx(x_i, 0)
>>> circuit.parameters
ParameterView([
ParameterVectorElement(x[0]), ParameterVectorElement(x[1]),
ParameterVectorElement(x[2]), ParameterVectorElement(x[3]),
..., ParameterVectorElement(x[11])
])
```
**Returns**
The sorted [`Parameter`](qiskit.circuit.Parameter "qiskit.circuit.Parameter") objects in the circuit.
</Attribute>
### preferred\_init\_points

View File

@ -117,7 +117,17 @@ $$
### data
<Attribute id="qiskit.circuit.library.ExcitationPreserving.data" />
<Attribute id="qiskit.circuit.library.ExcitationPreserving.data">
The circuit data (instructions and context).
**Returns**
a list-like object containing the [`CircuitInstruction`](qiskit.circuit.CircuitInstruction "qiskit.circuit.CircuitInstruction")s for each instruction.
**Return type**
QuantumCircuitData
</Attribute>
### entanglement
@ -241,7 +251,9 @@ $$
### num\_parameters
<Attribute id="qiskit.circuit.library.ExcitationPreserving.num_parameters" />
<Attribute id="qiskit.circuit.library.ExcitationPreserving.num_parameters">
The number of parameter objects in the circuit.
</Attribute>
### num\_parameters\_settable
@ -331,7 +343,61 @@ $$
### parameters
<Attribute id="qiskit.circuit.library.ExcitationPreserving.parameters" />
<Attribute id="qiskit.circuit.library.ExcitationPreserving.parameters">
The parameters defined in the circuit.
This attribute returns the [`Parameter`](qiskit.circuit.Parameter "qiskit.circuit.Parameter") objects in the circuit sorted alphabetically. Note that parameters instantiated with a [`ParameterVector`](qiskit.circuit.ParameterVector "qiskit.circuit.ParameterVector") are still sorted numerically.
**Examples**
The snippet below shows that insertion order of parameters does not matter.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter
>>> a, b, elephant = Parameter("a"), Parameter("b"), Parameter("elephant")
>>> circuit = QuantumCircuit(1)
>>> circuit.rx(b, 0)
>>> circuit.rz(elephant, 0)
>>> circuit.ry(a, 0)
>>> circuit.parameters # sorted alphabetically!
ParameterView([Parameter(a), Parameter(b), Parameter(elephant)])
```
Bear in mind that alphabetical sorting might be unintuitive when it comes to numbers. The literal “10” comes before “2” in strict alphabetical sorting.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter
>>> angles = [Parameter("angle_1"), Parameter("angle_2"), Parameter("angle_10")]
>>> circuit = QuantumCircuit(1)
>>> circuit.u(*angles, 0)
>>> circuit.draw()
┌─────────────────────────────┐
q: ┤ U(angle_1,angle_2,angle_10) ├
└─────────────────────────────┘
>>> circuit.parameters
ParameterView([Parameter(angle_1), Parameter(angle_10), Parameter(angle_2)])
```
To respect numerical sorting, a [`ParameterVector`](qiskit.circuit.ParameterVector "qiskit.circuit.ParameterVector") can be used.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter, ParameterVector
>>> x = ParameterVector("x", 12)
>>> circuit = QuantumCircuit(1)
>>> for x_i in x:
... circuit.rx(x_i, 0)
>>> circuit.parameters
ParameterView([
ParameterVectorElement(x[0]), ParameterVectorElement(x[1]),
ParameterVectorElement(x[2]), ParameterVectorElement(x[3]),
..., ParameterVectorElement(x[11])
])
```
**Returns**
The sorted [`Parameter`](qiskit.circuit.Parameter "qiskit.circuit.Parameter") objects in the circuit.
</Attribute>
### preferred\_init\_points

View File

@ -57,7 +57,17 @@ python_api_name: qiskit.circuit.library.FunctionalPauliRotations
### data
<Attribute id="qiskit.circuit.library.FunctionalPauliRotations.data" />
<Attribute id="qiskit.circuit.library.FunctionalPauliRotations.data">
The circuit data (instructions and context).
**Returns**
a list-like object containing the [`CircuitInstruction`](qiskit.circuit.CircuitInstruction "qiskit.circuit.CircuitInstruction")s for each instruction.
**Return type**
QuantumCircuitData
</Attribute>
### global\_phase
@ -135,7 +145,9 @@ python_api_name: qiskit.circuit.library.FunctionalPauliRotations
### num\_parameters
<Attribute id="qiskit.circuit.library.FunctionalPauliRotations.num_parameters" />
<Attribute id="qiskit.circuit.library.FunctionalPauliRotations.num_parameters">
The number of parameter objects in the circuit.
</Attribute>
### num\_qubits
@ -179,7 +191,61 @@ python_api_name: qiskit.circuit.library.FunctionalPauliRotations
### parameters
<Attribute id="qiskit.circuit.library.FunctionalPauliRotations.parameters" />
<Attribute id="qiskit.circuit.library.FunctionalPauliRotations.parameters">
The parameters defined in the circuit.
This attribute returns the [`Parameter`](qiskit.circuit.Parameter "qiskit.circuit.Parameter") objects in the circuit sorted alphabetically. Note that parameters instantiated with a [`ParameterVector`](qiskit.circuit.ParameterVector "qiskit.circuit.ParameterVector") are still sorted numerically.
**Examples**
The snippet below shows that insertion order of parameters does not matter.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter
>>> a, b, elephant = Parameter("a"), Parameter("b"), Parameter("elephant")
>>> circuit = QuantumCircuit(1)
>>> circuit.rx(b, 0)
>>> circuit.rz(elephant, 0)
>>> circuit.ry(a, 0)
>>> circuit.parameters # sorted alphabetically!
ParameterView([Parameter(a), Parameter(b), Parameter(elephant)])
```
Bear in mind that alphabetical sorting might be unintuitive when it comes to numbers. The literal “10” comes before “2” in strict alphabetical sorting.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter
>>> angles = [Parameter("angle_1"), Parameter("angle_2"), Parameter("angle_10")]
>>> circuit = QuantumCircuit(1)
>>> circuit.u(*angles, 0)
>>> circuit.draw()
┌─────────────────────────────┐
q: ┤ U(angle_1,angle_2,angle_10) ├
└─────────────────────────────┘
>>> circuit.parameters
ParameterView([Parameter(angle_1), Parameter(angle_10), Parameter(angle_2)])
```
To respect numerical sorting, a [`ParameterVector`](qiskit.circuit.ParameterVector "qiskit.circuit.ParameterVector") can be used.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter, ParameterVector
>>> x = ParameterVector("x", 12)
>>> circuit = QuantumCircuit(1)
>>> for x_i in x:
... circuit.rx(x_i, 0)
>>> circuit.parameters
ParameterView([
ParameterVectorElement(x[0]), ParameterVectorElement(x[1]),
ParameterVectorElement(x[2]), ParameterVectorElement(x[3]),
..., ParameterVectorElement(x[11])
])
```
**Returns**
The sorted [`Parameter`](qiskit.circuit.Parameter "qiskit.circuit.Parameter") objects in the circuit.
</Attribute>
### prefix

View File

@ -54,7 +54,17 @@ $$
### data
<Attribute id="qiskit.circuit.library.IntegerComparator.data" />
<Attribute id="qiskit.circuit.library.IntegerComparator.data">
The circuit data (instructions and context).
**Returns**
a list-like object containing the [`CircuitInstruction`](qiskit.circuit.CircuitInstruction "qiskit.circuit.CircuitInstruction")s for each instruction.
**Return type**
QuantumCircuitData
</Attribute>
### geq
@ -132,7 +142,9 @@ $$
### num\_parameters
<Attribute id="qiskit.circuit.library.IntegerComparator.num_parameters" />
<Attribute id="qiskit.circuit.library.IntegerComparator.num_parameters">
The number of parameter objects in the circuit.
</Attribute>
### num\_qubits
@ -176,7 +188,61 @@ $$
### parameters
<Attribute id="qiskit.circuit.library.IntegerComparator.parameters" />
<Attribute id="qiskit.circuit.library.IntegerComparator.parameters">
The parameters defined in the circuit.
This attribute returns the [`Parameter`](qiskit.circuit.Parameter "qiskit.circuit.Parameter") objects in the circuit sorted alphabetically. Note that parameters instantiated with a [`ParameterVector`](qiskit.circuit.ParameterVector "qiskit.circuit.ParameterVector") are still sorted numerically.
**Examples**
The snippet below shows that insertion order of parameters does not matter.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter
>>> a, b, elephant = Parameter("a"), Parameter("b"), Parameter("elephant")
>>> circuit = QuantumCircuit(1)
>>> circuit.rx(b, 0)
>>> circuit.rz(elephant, 0)
>>> circuit.ry(a, 0)
>>> circuit.parameters # sorted alphabetically!
ParameterView([Parameter(a), Parameter(b), Parameter(elephant)])
```
Bear in mind that alphabetical sorting might be unintuitive when it comes to numbers. The literal “10” comes before “2” in strict alphabetical sorting.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter
>>> angles = [Parameter("angle_1"), Parameter("angle_2"), Parameter("angle_10")]
>>> circuit = QuantumCircuit(1)
>>> circuit.u(*angles, 0)
>>> circuit.draw()
┌─────────────────────────────┐
q: ┤ U(angle_1,angle_2,angle_10) ├
└─────────────────────────────┘
>>> circuit.parameters
ParameterView([Parameter(angle_1), Parameter(angle_10), Parameter(angle_2)])
```
To respect numerical sorting, a [`ParameterVector`](qiskit.circuit.ParameterVector "qiskit.circuit.ParameterVector") can be used.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter, ParameterVector
>>> x = ParameterVector("x", 12)
>>> circuit = QuantumCircuit(1)
>>> for x_i in x:
... circuit.rx(x_i, 0)
>>> circuit.parameters
ParameterView([
ParameterVectorElement(x[0]), ParameterVectorElement(x[1]),
ParameterVectorElement(x[2]), ParameterVectorElement(x[3]),
..., ParameterVectorElement(x[11])
])
```
**Returns**
The sorted [`Parameter`](qiskit.circuit.Parameter "qiskit.circuit.Parameter") objects in the circuit.
</Attribute>
### prefix

View File

@ -80,7 +80,17 @@ $$
### data
<Attribute id="qiskit.circuit.library.LinearPauliRotations.data" />
<Attribute id="qiskit.circuit.library.LinearPauliRotations.data">
The circuit data (instructions and context).
**Returns**
a list-like object containing the [`CircuitInstruction`](qiskit.circuit.CircuitInstruction "qiskit.circuit.CircuitInstruction")s for each instruction.
**Return type**
QuantumCircuitData
</Attribute>
### global\_phase
@ -158,7 +168,9 @@ $$
### num\_parameters
<Attribute id="qiskit.circuit.library.LinearPauliRotations.num_parameters" />
<Attribute id="qiskit.circuit.library.LinearPauliRotations.num_parameters">
The number of parameter objects in the circuit.
</Attribute>
### num\_qubits
@ -214,7 +226,61 @@ $$
### parameters
<Attribute id="qiskit.circuit.library.LinearPauliRotations.parameters" />
<Attribute id="qiskit.circuit.library.LinearPauliRotations.parameters">
The parameters defined in the circuit.
This attribute returns the [`Parameter`](qiskit.circuit.Parameter "qiskit.circuit.Parameter") objects in the circuit sorted alphabetically. Note that parameters instantiated with a [`ParameterVector`](qiskit.circuit.ParameterVector "qiskit.circuit.ParameterVector") are still sorted numerically.
**Examples**
The snippet below shows that insertion order of parameters does not matter.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter
>>> a, b, elephant = Parameter("a"), Parameter("b"), Parameter("elephant")
>>> circuit = QuantumCircuit(1)
>>> circuit.rx(b, 0)
>>> circuit.rz(elephant, 0)
>>> circuit.ry(a, 0)
>>> circuit.parameters # sorted alphabetically!
ParameterView([Parameter(a), Parameter(b), Parameter(elephant)])
```
Bear in mind that alphabetical sorting might be unintuitive when it comes to numbers. The literal “10” comes before “2” in strict alphabetical sorting.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter
>>> angles = [Parameter("angle_1"), Parameter("angle_2"), Parameter("angle_10")]
>>> circuit = QuantumCircuit(1)
>>> circuit.u(*angles, 0)
>>> circuit.draw()
┌─────────────────────────────┐
q: ┤ U(angle_1,angle_2,angle_10) ├
└─────────────────────────────┘
>>> circuit.parameters
ParameterView([Parameter(angle_1), Parameter(angle_10), Parameter(angle_2)])
```
To respect numerical sorting, a [`ParameterVector`](qiskit.circuit.ParameterVector "qiskit.circuit.ParameterVector") can be used.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter, ParameterVector
>>> x = ParameterVector("x", 12)
>>> circuit = QuantumCircuit(1)
>>> for x_i in x:
... circuit.rx(x_i, 0)
>>> circuit.parameters
ParameterView([
ParameterVectorElement(x[0]), ParameterVectorElement(x[1]),
ParameterVectorElement(x[2]), ParameterVectorElement(x[3]),
..., ParameterVectorElement(x[11])
])
```
**Returns**
The sorted [`Parameter`](qiskit.circuit.Parameter "qiskit.circuit.Parameter") objects in the circuit.
</Attribute>
### prefix

View File

@ -84,7 +84,17 @@ python_api_name: qiskit.circuit.library.NLocal
### data
<Attribute id="qiskit.circuit.library.NLocal.data" />
<Attribute id="qiskit.circuit.library.NLocal.data">
The circuit data (instructions and context).
**Returns**
a list-like object containing the [`CircuitInstruction`](qiskit.circuit.CircuitInstruction "qiskit.circuit.CircuitInstruction")s for each instruction.
**Return type**
QuantumCircuitData
</Attribute>
### entanglement
@ -208,7 +218,9 @@ python_api_name: qiskit.circuit.library.NLocal
### num\_parameters
<Attribute id="qiskit.circuit.library.NLocal.num_parameters" />
<Attribute id="qiskit.circuit.library.NLocal.num_parameters">
The number of parameter objects in the circuit.
</Attribute>
### num\_parameters\_settable
@ -298,7 +310,61 @@ python_api_name: qiskit.circuit.library.NLocal
### parameters
<Attribute id="qiskit.circuit.library.NLocal.parameters" />
<Attribute id="qiskit.circuit.library.NLocal.parameters">
The parameters defined in the circuit.
This attribute returns the [`Parameter`](qiskit.circuit.Parameter "qiskit.circuit.Parameter") objects in the circuit sorted alphabetically. Note that parameters instantiated with a [`ParameterVector`](qiskit.circuit.ParameterVector "qiskit.circuit.ParameterVector") are still sorted numerically.
**Examples**
The snippet below shows that insertion order of parameters does not matter.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter
>>> a, b, elephant = Parameter("a"), Parameter("b"), Parameter("elephant")
>>> circuit = QuantumCircuit(1)
>>> circuit.rx(b, 0)
>>> circuit.rz(elephant, 0)
>>> circuit.ry(a, 0)
>>> circuit.parameters # sorted alphabetically!
ParameterView([Parameter(a), Parameter(b), Parameter(elephant)])
```
Bear in mind that alphabetical sorting might be unintuitive when it comes to numbers. The literal “10” comes before “2” in strict alphabetical sorting.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter
>>> angles = [Parameter("angle_1"), Parameter("angle_2"), Parameter("angle_10")]
>>> circuit = QuantumCircuit(1)
>>> circuit.u(*angles, 0)
>>> circuit.draw()
┌─────────────────────────────┐
q: ┤ U(angle_1,angle_2,angle_10) ├
└─────────────────────────────┘
>>> circuit.parameters
ParameterView([Parameter(angle_1), Parameter(angle_10), Parameter(angle_2)])
```
To respect numerical sorting, a [`ParameterVector`](qiskit.circuit.ParameterVector "qiskit.circuit.ParameterVector") can be used.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter, ParameterVector
>>> x = ParameterVector("x", 12)
>>> circuit = QuantumCircuit(1)
>>> for x_i in x:
... circuit.rx(x_i, 0)
>>> circuit.parameters
ParameterView([
ParameterVectorElement(x[0]), ParameterVectorElement(x[1]),
ParameterVectorElement(x[2]), ParameterVectorElement(x[3]),
..., ParameterVectorElement(x[11])
])
```
**Returns**
The sorted [`Parameter`](qiskit.circuit.Parameter "qiskit.circuit.Parameter") objects in the circuit.
</Attribute>
### preferred\_init\_points

View File

@ -8,7 +8,7 @@ python_api_name: qiskit.circuit.library.PauliFeatureMap
# PauliFeatureMap
<Class id="qiskit.circuit.library.PauliFeatureMap" isDedicatedPage={true} github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/circuit/library/data_preparation/pauli_feature_map.py#L26-L282" signature="qiskit.circuit.library.PauliFeatureMap(feature_dimension=None, reps=2, entanglement='full', alpha=2.0, paulis=None, data_map_func=None, parameter_prefix='x', insert_barriers=False, name='PauliFeatureMap')" modifiers="class">
<Class id="qiskit.circuit.library.PauliFeatureMap" isDedicatedPage={true} github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/circuit/library/data_preparation/pauli_feature_map.py#L26-L287" signature="qiskit.circuit.library.PauliFeatureMap(feature_dimension=None, reps=2, entanglement='full', alpha=2.0, paulis=None, data_map_func=None, parameter_prefix='x', insert_barriers=False, name='PauliFeatureMap')" modifiers="class">
Bases: [`NLocal`](qiskit.circuit.library.NLocal "qiskit.circuit.library.n_local.n_local.NLocal")
The Pauli Expansion circuit.
@ -38,11 +38,11 @@ $$
which will produce blocks of the form
```python
┌───┐┌─────────────┐┌──────────┐ ┌───────────┐
┤ H ├┤ U1(2.0*x[0]) ├┤ RX(pi/2) ├──■───────────────────────────────────────■──┤ RX(-pi/2) ├
├───┤├─────────────┤├──────────┤┌─┴─┐┌────────────────────────────────┐┌─┴─┐├───────────┤
┤ H ├┤ U1(2.0*x[1]) ├┤ RX(pi/2) ├┤ X ├┤ U1(2.0*(pi - x[0])*(pi - x[1])) ├┤ X ├┤ RX(-pi/2) ├
└───┘└─────────────┘└──────────┘└───┘└────────────────────────────────┘└───┘└───────────┘
┌───┐┌─────────────┐┌──────────┐ ┌───────────┐
┤ H ├┤ P(2.0*x[0]) ├┤ RX(pi/2) ├──■──────────────────────────────────────■──┤ RX(-pi/2) ├
├───┤├─────────────┤├──────────┤┌─┴─┐┌────────────────────────────────┐┌─┴─┐├───────────┤
┤ H ├┤ P(2.0*x[1]) ├┤ RX(pi/2) ├┤ X ├┤ P(2.0*(pi - x[0])*(pi - x[1])) ├┤ X ├┤ RX(-pi/2) ├
└───┘└─────────────┘└──────────┘└───┘└────────────────────────────────┘└───┘└───────────┘
```
The circuit contains `reps` repetitions of this transformation.
@ -53,43 +53,43 @@ $$
```python
>>> prep = PauliFeatureMap(2, reps=1, paulis=['ZZ'])
>>> print(prep)
>>> print(prep.decompose())
┌───┐
q_0: ┤ H ├──■──────────────────────────────────────■──
├───┤┌─┴─┐┌────────────────────────────────┐┌─┴─┐
q_1: ┤ H ├┤ X ├┤ U1(2.0*(pi - x[0])*(pi - x[1])) ├┤ X ├
└───┘└───┘└────────────────────────────────┘└───┘
q_0: ┤ H ├──■──────────────────────────────────────■──
├───┤┌─┴─┐┌────────────────────────────────┐┌─┴─┐
q_1: ┤ H ├┤ X ├┤ P(2.0*(pi - x[0])*(pi - x[1])) ├┤ X ├
└───┘└───┘└────────────────────────────────┘└───┘
```
```python
>>> prep = PauliFeatureMap(2, reps=1, paulis=['Z', 'XX'])
>>> print(prep)
┌───┐┌─────────────┐┌───┐ ┌───┐
q_0: ┤ H ├┤ U1(2.0*x[0]) ├┤ H ├──■───────────────────────────────────────■──┤ H ├
├───┤├─────────────┤├───┤┌─┴─┐┌────────────────────────────────┐┌─┴─┐├───┤
q_1: ┤ H ├┤ U1(2.0*x[1]) ├┤ H ├┤ X ├┤ U1(2.0*(pi - x[0])*(pi - x[1])) ├┤ X ├┤ H ├
└───┘└─────────────┘└───┘└───┘└────────────────────────────────┘└───┘└───┘
>>> print(prep.decompose())
┌───┐┌─────────────┐┌───┐ ┌───┐
q_0: ┤ H ├┤ P(2.0*x[0]) ├┤ H ├──■──────────────────────────────────────■──┤ H ├
├───┤├─────────────┤├───┤┌─┴─┐┌────────────────────────────────┐┌─┴─┐├───┤
q_1: ┤ H ├┤ P(2.0*x[1]) ├┤ H ├┤ X ├┤ P(2.0*(pi - x[0])*(pi - x[1])) ├┤ X ├┤ H ├
└───┘└─────────────┘└───┘└───┘└────────────────────────────────┘└───┘└───┘
```
```python
>>> prep = PauliFeatureMap(2, reps=1, paulis=['ZY'])
>>> print(prep)
>>> print(prep.decompose())
┌───┐┌──────────┐ ┌───────────┐
q_0: ┤ H ├┤ RX(pi/2) ├──■──────────────────────────────────────■──┤ RX(-pi/2) ├
├───┤└──────────┘┌─┴─┐┌────────────────────────────────┐┌─┴─┐└───────────┘
q_1: ┤ H ├────────────┤ X ├┤ U1(2.0*(pi - x[0])*(pi - x[1])) ├┤ X ├─────────────
└───┘ └───┘└────────────────────────────────┘└───┘
q_0: ┤ H ├┤ RX(pi/2) ├──■──────────────────────────────────────■──┤ RX(-pi/2) ├
├───┤└──────────┘┌─┴─┐┌────────────────────────────────┐┌─┴─┐└───────────┘
q_1: ┤ H ├────────────┤ X ├┤ P(2.0*(pi - x[0])*(pi - x[1])) ├┤ X ├─────────────
└───┘ └───┘└────────────────────────────────┘└───┘
```
```python
>>> from qiskit.circuit.library import EfficientSU2
>>> prep = PauliFeatureMap(3, reps=3, paulis=['Z', 'YY', 'ZXZ'])
>>> wavefunction = EfficientSU2(3)
>>> classifier = prep.compose(wavefunction)
>>> classifier = prep.compose(wavefunction).decompose()
>>> classifier.num_parameters
27
>>> classifier.count_ops()
OrderedDict([('cx', 39), ('rx', 36), ('u1', 21), ('h', 15), ('ry', 12), ('rz', 12)])
OrderedDict([('cx', 39), ('rx', 36), ('p', 21), ('h', 15), ('ry', 12), ('rz', 12)])
```
References:
@ -143,7 +143,17 @@ $$
### data
<Attribute id="qiskit.circuit.library.PauliFeatureMap.data" />
<Attribute id="qiskit.circuit.library.PauliFeatureMap.data">
The circuit data (instructions and context).
**Returns**
a list-like object containing the [`CircuitInstruction`](qiskit.circuit.CircuitInstruction "qiskit.circuit.CircuitInstruction")s for each instruction.
**Return type**
QuantumCircuitData
</Attribute>
### entanglement
@ -157,7 +167,13 @@ $$
### entanglement\_blocks
<Attribute id="qiskit.circuit.library.PauliFeatureMap.entanglement_blocks" />
<Attribute id="qiskit.circuit.library.PauliFeatureMap.entanglement_blocks">
The blocks in the entanglement layers.
**Returns**
The blocks in the entanglement layers.
</Attribute>
### feature\_dimension
@ -271,7 +287,9 @@ $$
### num\_parameters
<Attribute id="qiskit.circuit.library.PauliFeatureMap.num_parameters" />
<Attribute id="qiskit.circuit.library.PauliFeatureMap.num_parameters">
The number of parameter objects in the circuit.
</Attribute>
### num\_parameters\_settable
@ -351,7 +369,61 @@ $$
### parameters
<Attribute id="qiskit.circuit.library.PauliFeatureMap.parameters" />
<Attribute id="qiskit.circuit.library.PauliFeatureMap.parameters">
The parameters defined in the circuit.
This attribute returns the [`Parameter`](qiskit.circuit.Parameter "qiskit.circuit.Parameter") objects in the circuit sorted alphabetically. Note that parameters instantiated with a [`ParameterVector`](qiskit.circuit.ParameterVector "qiskit.circuit.ParameterVector") are still sorted numerically.
**Examples**
The snippet below shows that insertion order of parameters does not matter.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter
>>> a, b, elephant = Parameter("a"), Parameter("b"), Parameter("elephant")
>>> circuit = QuantumCircuit(1)
>>> circuit.rx(b, 0)
>>> circuit.rz(elephant, 0)
>>> circuit.ry(a, 0)
>>> circuit.parameters # sorted alphabetically!
ParameterView([Parameter(a), Parameter(b), Parameter(elephant)])
```
Bear in mind that alphabetical sorting might be unintuitive when it comes to numbers. The literal “10” comes before “2” in strict alphabetical sorting.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter
>>> angles = [Parameter("angle_1"), Parameter("angle_2"), Parameter("angle_10")]
>>> circuit = QuantumCircuit(1)
>>> circuit.u(*angles, 0)
>>> circuit.draw()
┌─────────────────────────────┐
q: ┤ U(angle_1,angle_2,angle_10) ├
└─────────────────────────────┘
>>> circuit.parameters
ParameterView([Parameter(angle_1), Parameter(angle_10), Parameter(angle_2)])
```
To respect numerical sorting, a [`ParameterVector`](qiskit.circuit.ParameterVector "qiskit.circuit.ParameterVector") can be used.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter, ParameterVector
>>> x = ParameterVector("x", 12)
>>> circuit = QuantumCircuit(1)
>>> for x_i in x:
... circuit.rx(x_i, 0)
>>> circuit.parameters
ParameterView([
ParameterVectorElement(x[0]), ParameterVectorElement(x[1]),
ParameterVectorElement(x[2]), ParameterVectorElement(x[3]),
..., ParameterVectorElement(x[11])
])
```
**Returns**
The sorted [`Parameter`](qiskit.circuit.Parameter "qiskit.circuit.Parameter") objects in the circuit.
</Attribute>
### paulis
@ -437,13 +509,13 @@ $$
### pauli\_block
<Function id="qiskit.circuit.library.PauliFeatureMap.pauli_block" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/circuit/library/data_preparation/pauli_feature_map.py#L241-L245" signature="pauli_block(pauli_string)">
<Function id="qiskit.circuit.library.PauliFeatureMap.pauli_block" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/circuit/library/data_preparation/pauli_feature_map.py#L246-L250" signature="pauli_block(pauli_string)">
Get the Pauli block for the feature map circuit.
</Function>
### pauli\_evolution
<Function id="qiskit.circuit.library.PauliFeatureMap.pauli_evolution" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/circuit/library/data_preparation/pauli_feature_map.py#L247-L282" signature="pauli_evolution(pauli_string, time)">
<Function id="qiskit.circuit.library.PauliFeatureMap.pauli_evolution" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/circuit/library/data_preparation/pauli_feature_map.py#L252-L287" signature="pauli_evolution(pauli_string, time)">
Get the evolution block for the given pauli string.
</Function>
</Class>

View File

@ -82,7 +82,17 @@ python_api_name: qiskit.circuit.library.PauliTwoDesign
### data
<Attribute id="qiskit.circuit.library.PauliTwoDesign.data" />
<Attribute id="qiskit.circuit.library.PauliTwoDesign.data">
The circuit data (instructions and context).
**Returns**
a list-like object containing the [`CircuitInstruction`](qiskit.circuit.CircuitInstruction "qiskit.circuit.CircuitInstruction")s for each instruction.
**Return type**
QuantumCircuitData
</Attribute>
### entanglement
@ -206,7 +216,9 @@ python_api_name: qiskit.circuit.library.PauliTwoDesign
### num\_parameters
<Attribute id="qiskit.circuit.library.PauliTwoDesign.num_parameters" />
<Attribute id="qiskit.circuit.library.PauliTwoDesign.num_parameters">
The number of parameter objects in the circuit.
</Attribute>
### num\_parameters\_settable
@ -290,7 +302,61 @@ python_api_name: qiskit.circuit.library.PauliTwoDesign
### parameters
<Attribute id="qiskit.circuit.library.PauliTwoDesign.parameters" />
<Attribute id="qiskit.circuit.library.PauliTwoDesign.parameters">
The parameters defined in the circuit.
This attribute returns the [`Parameter`](qiskit.circuit.Parameter "qiskit.circuit.Parameter") objects in the circuit sorted alphabetically. Note that parameters instantiated with a [`ParameterVector`](qiskit.circuit.ParameterVector "qiskit.circuit.ParameterVector") are still sorted numerically.
**Examples**
The snippet below shows that insertion order of parameters does not matter.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter
>>> a, b, elephant = Parameter("a"), Parameter("b"), Parameter("elephant")
>>> circuit = QuantumCircuit(1)
>>> circuit.rx(b, 0)
>>> circuit.rz(elephant, 0)
>>> circuit.ry(a, 0)
>>> circuit.parameters # sorted alphabetically!
ParameterView([Parameter(a), Parameter(b), Parameter(elephant)])
```
Bear in mind that alphabetical sorting might be unintuitive when it comes to numbers. The literal “10” comes before “2” in strict alphabetical sorting.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter
>>> angles = [Parameter("angle_1"), Parameter("angle_2"), Parameter("angle_10")]
>>> circuit = QuantumCircuit(1)
>>> circuit.u(*angles, 0)
>>> circuit.draw()
┌─────────────────────────────┐
q: ┤ U(angle_1,angle_2,angle_10) ├
└─────────────────────────────┘
>>> circuit.parameters
ParameterView([Parameter(angle_1), Parameter(angle_10), Parameter(angle_2)])
```
To respect numerical sorting, a [`ParameterVector`](qiskit.circuit.ParameterVector "qiskit.circuit.ParameterVector") can be used.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter, ParameterVector
>>> x = ParameterVector("x", 12)
>>> circuit = QuantumCircuit(1)
>>> for x_i in x:
... circuit.rx(x_i, 0)
>>> circuit.parameters
ParameterView([
ParameterVectorElement(x[0]), ParameterVectorElement(x[1]),
ParameterVectorElement(x[2]), ParameterVectorElement(x[3]),
..., ParameterVectorElement(x[11])
])
```
**Returns**
The sorted [`Parameter`](qiskit.circuit.Parameter "qiskit.circuit.Parameter") objects in the circuit.
</Attribute>
### preferred\_init\_points

View File

@ -86,7 +86,17 @@ python_api_name: qiskit.circuit.library.PiecewiseChebyshev
### data
<Attribute id="qiskit.circuit.library.PiecewiseChebyshev.data" />
<Attribute id="qiskit.circuit.library.PiecewiseChebyshev.data">
The circuit data (instructions and context).
**Returns**
a list-like object containing the [`CircuitInstruction`](qiskit.circuit.CircuitInstruction "qiskit.circuit.CircuitInstruction")s for each instruction.
**Return type**
QuantumCircuitData
</Attribute>
### degree
@ -174,7 +184,9 @@ python_api_name: qiskit.circuit.library.PiecewiseChebyshev
### num\_parameters
<Attribute id="qiskit.circuit.library.PiecewiseChebyshev.num_parameters" />
<Attribute id="qiskit.circuit.library.PiecewiseChebyshev.num_parameters">
The number of parameter objects in the circuit.
</Attribute>
### num\_qubits
@ -218,7 +230,61 @@ python_api_name: qiskit.circuit.library.PiecewiseChebyshev
### parameters
<Attribute id="qiskit.circuit.library.PiecewiseChebyshev.parameters" />
<Attribute id="qiskit.circuit.library.PiecewiseChebyshev.parameters">
The parameters defined in the circuit.
This attribute returns the [`Parameter`](qiskit.circuit.Parameter "qiskit.circuit.Parameter") objects in the circuit sorted alphabetically. Note that parameters instantiated with a [`ParameterVector`](qiskit.circuit.ParameterVector "qiskit.circuit.ParameterVector") are still sorted numerically.
**Examples**
The snippet below shows that insertion order of parameters does not matter.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter
>>> a, b, elephant = Parameter("a"), Parameter("b"), Parameter("elephant")
>>> circuit = QuantumCircuit(1)
>>> circuit.rx(b, 0)
>>> circuit.rz(elephant, 0)
>>> circuit.ry(a, 0)
>>> circuit.parameters # sorted alphabetically!
ParameterView([Parameter(a), Parameter(b), Parameter(elephant)])
```
Bear in mind that alphabetical sorting might be unintuitive when it comes to numbers. The literal “10” comes before “2” in strict alphabetical sorting.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter
>>> angles = [Parameter("angle_1"), Parameter("angle_2"), Parameter("angle_10")]
>>> circuit = QuantumCircuit(1)
>>> circuit.u(*angles, 0)
>>> circuit.draw()
┌─────────────────────────────┐
q: ┤ U(angle_1,angle_2,angle_10) ├
└─────────────────────────────┘
>>> circuit.parameters
ParameterView([Parameter(angle_1), Parameter(angle_10), Parameter(angle_2)])
```
To respect numerical sorting, a [`ParameterVector`](qiskit.circuit.ParameterVector "qiskit.circuit.ParameterVector") can be used.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter, ParameterVector
>>> x = ParameterVector("x", 12)
>>> circuit = QuantumCircuit(1)
>>> for x_i in x:
... circuit.rx(x_i, 0)
>>> circuit.parameters
ParameterView([
ParameterVectorElement(x[0]), ParameterVectorElement(x[1]),
ParameterVectorElement(x[2]), ParameterVectorElement(x[3]),
..., ParameterVectorElement(x[11])
])
```
**Returns**
The sorted [`Parameter`](qiskit.circuit.Parameter "qiskit.circuit.Parameter") objects in the circuit.
</Attribute>
### polynomials

View File

@ -89,7 +89,17 @@ $$
### data
<Attribute id="qiskit.circuit.library.PiecewiseLinearPauliRotations.data" />
<Attribute id="qiskit.circuit.library.PiecewiseLinearPauliRotations.data">
The circuit data (instructions and context).
**Returns**
a list-like object containing the [`CircuitInstruction`](qiskit.circuit.CircuitInstruction "qiskit.circuit.CircuitInstruction")s for each instruction.
**Return type**
QuantumCircuitData
</Attribute>
### global\_phase
@ -187,7 +197,9 @@ $$
### num\_parameters
<Attribute id="qiskit.circuit.library.PiecewiseLinearPauliRotations.num_parameters" />
<Attribute id="qiskit.circuit.library.PiecewiseLinearPauliRotations.num_parameters">
The number of parameter objects in the circuit.
</Attribute>
### num\_qubits
@ -239,7 +251,61 @@ $$
### parameters
<Attribute id="qiskit.circuit.library.PiecewiseLinearPauliRotations.parameters" />
<Attribute id="qiskit.circuit.library.PiecewiseLinearPauliRotations.parameters">
The parameters defined in the circuit.
This attribute returns the [`Parameter`](qiskit.circuit.Parameter "qiskit.circuit.Parameter") objects in the circuit sorted alphabetically. Note that parameters instantiated with a [`ParameterVector`](qiskit.circuit.ParameterVector "qiskit.circuit.ParameterVector") are still sorted numerically.
**Examples**
The snippet below shows that insertion order of parameters does not matter.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter
>>> a, b, elephant = Parameter("a"), Parameter("b"), Parameter("elephant")
>>> circuit = QuantumCircuit(1)
>>> circuit.rx(b, 0)
>>> circuit.rz(elephant, 0)
>>> circuit.ry(a, 0)
>>> circuit.parameters # sorted alphabetically!
ParameterView([Parameter(a), Parameter(b), Parameter(elephant)])
```
Bear in mind that alphabetical sorting might be unintuitive when it comes to numbers. The literal “10” comes before “2” in strict alphabetical sorting.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter
>>> angles = [Parameter("angle_1"), Parameter("angle_2"), Parameter("angle_10")]
>>> circuit = QuantumCircuit(1)
>>> circuit.u(*angles, 0)
>>> circuit.draw()
┌─────────────────────────────┐
q: ┤ U(angle_1,angle_2,angle_10) ├
└─────────────────────────────┘
>>> circuit.parameters
ParameterView([Parameter(angle_1), Parameter(angle_10), Parameter(angle_2)])
```
To respect numerical sorting, a [`ParameterVector`](qiskit.circuit.ParameterVector "qiskit.circuit.ParameterVector") can be used.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter, ParameterVector
>>> x = ParameterVector("x", 12)
>>> circuit = QuantumCircuit(1)
>>> for x_i in x:
... circuit.rx(x_i, 0)
>>> circuit.parameters
ParameterView([
ParameterVectorElement(x[0]), ParameterVectorElement(x[1]),
ParameterVectorElement(x[2]), ParameterVectorElement(x[3]),
..., ParameterVectorElement(x[11])
])
```
**Returns**
The sorted [`Parameter`](qiskit.circuit.Parameter "qiskit.circuit.Parameter") objects in the circuit.
</Attribute>
### prefix

View File

@ -147,7 +147,17 @@ $$
### data
<Attribute id="qiskit.circuit.library.PiecewisePolynomialPauliRotations.data" />
<Attribute id="qiskit.circuit.library.PiecewisePolynomialPauliRotations.data">
The circuit data (instructions and context).
**Returns**
a list-like object containing the [`CircuitInstruction`](qiskit.circuit.CircuitInstruction "qiskit.circuit.CircuitInstruction")s for each instruction.
**Return type**
QuantumCircuitData
</Attribute>
### global\_phase
@ -235,7 +245,9 @@ $$
### num\_parameters
<Attribute id="qiskit.circuit.library.PiecewisePolynomialPauliRotations.num_parameters" />
<Attribute id="qiskit.circuit.library.PiecewisePolynomialPauliRotations.num_parameters">
The number of parameter objects in the circuit.
</Attribute>
### num\_qubits
@ -279,7 +291,61 @@ $$
### parameters
<Attribute id="qiskit.circuit.library.PiecewisePolynomialPauliRotations.parameters" />
<Attribute id="qiskit.circuit.library.PiecewisePolynomialPauliRotations.parameters">
The parameters defined in the circuit.
This attribute returns the [`Parameter`](qiskit.circuit.Parameter "qiskit.circuit.Parameter") objects in the circuit sorted alphabetically. Note that parameters instantiated with a [`ParameterVector`](qiskit.circuit.ParameterVector "qiskit.circuit.ParameterVector") are still sorted numerically.
**Examples**
The snippet below shows that insertion order of parameters does not matter.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter
>>> a, b, elephant = Parameter("a"), Parameter("b"), Parameter("elephant")
>>> circuit = QuantumCircuit(1)
>>> circuit.rx(b, 0)
>>> circuit.rz(elephant, 0)
>>> circuit.ry(a, 0)
>>> circuit.parameters # sorted alphabetically!
ParameterView([Parameter(a), Parameter(b), Parameter(elephant)])
```
Bear in mind that alphabetical sorting might be unintuitive when it comes to numbers. The literal “10” comes before “2” in strict alphabetical sorting.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter
>>> angles = [Parameter("angle_1"), Parameter("angle_2"), Parameter("angle_10")]
>>> circuit = QuantumCircuit(1)
>>> circuit.u(*angles, 0)
>>> circuit.draw()
┌─────────────────────────────┐
q: ┤ U(angle_1,angle_2,angle_10) ├
└─────────────────────────────┘
>>> circuit.parameters
ParameterView([Parameter(angle_1), Parameter(angle_10), Parameter(angle_2)])
```
To respect numerical sorting, a [`ParameterVector`](qiskit.circuit.ParameterVector "qiskit.circuit.ParameterVector") can be used.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter, ParameterVector
>>> x = ParameterVector("x", 12)
>>> circuit = QuantumCircuit(1)
>>> for x_i in x:
... circuit.rx(x_i, 0)
>>> circuit.parameters
ParameterView([
ParameterVectorElement(x[0]), ParameterVectorElement(x[1]),
ParameterVectorElement(x[2]), ParameterVectorElement(x[3]),
..., ParameterVectorElement(x[11])
])
```
**Returns**
The sorted [`Parameter`](qiskit.circuit.Parameter "qiskit.circuit.Parameter") objects in the circuit.
</Attribute>
### prefix

View File

@ -97,7 +97,17 @@ $$
### data
<Attribute id="qiskit.circuit.library.PolynomialPauliRotations.data" />
<Attribute id="qiskit.circuit.library.PolynomialPauliRotations.data">
The circuit data (instructions and context).
**Returns**
a list-like object containing the [`CircuitInstruction`](qiskit.circuit.CircuitInstruction "qiskit.circuit.CircuitInstruction")s for each instruction.
**Return type**
QuantumCircuitData
</Attribute>
### degree
@ -185,7 +195,9 @@ $$
### num\_parameters
<Attribute id="qiskit.circuit.library.PolynomialPauliRotations.num_parameters" />
<Attribute id="qiskit.circuit.library.PolynomialPauliRotations.num_parameters">
The number of parameter objects in the circuit.
</Attribute>
### num\_qubits
@ -229,7 +241,61 @@ $$
### parameters
<Attribute id="qiskit.circuit.library.PolynomialPauliRotations.parameters" />
<Attribute id="qiskit.circuit.library.PolynomialPauliRotations.parameters">
The parameters defined in the circuit.
This attribute returns the [`Parameter`](qiskit.circuit.Parameter "qiskit.circuit.Parameter") objects in the circuit sorted alphabetically. Note that parameters instantiated with a [`ParameterVector`](qiskit.circuit.ParameterVector "qiskit.circuit.ParameterVector") are still sorted numerically.
**Examples**
The snippet below shows that insertion order of parameters does not matter.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter
>>> a, b, elephant = Parameter("a"), Parameter("b"), Parameter("elephant")
>>> circuit = QuantumCircuit(1)
>>> circuit.rx(b, 0)
>>> circuit.rz(elephant, 0)
>>> circuit.ry(a, 0)
>>> circuit.parameters # sorted alphabetically!
ParameterView([Parameter(a), Parameter(b), Parameter(elephant)])
```
Bear in mind that alphabetical sorting might be unintuitive when it comes to numbers. The literal “10” comes before “2” in strict alphabetical sorting.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter
>>> angles = [Parameter("angle_1"), Parameter("angle_2"), Parameter("angle_10")]
>>> circuit = QuantumCircuit(1)
>>> circuit.u(*angles, 0)
>>> circuit.draw()
┌─────────────────────────────┐
q: ┤ U(angle_1,angle_2,angle_10) ├
└─────────────────────────────┘
>>> circuit.parameters
ParameterView([Parameter(angle_1), Parameter(angle_10), Parameter(angle_2)])
```
To respect numerical sorting, a [`ParameterVector`](qiskit.circuit.ParameterVector "qiskit.circuit.ParameterVector") can be used.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter, ParameterVector
>>> x = ParameterVector("x", 12)
>>> circuit = QuantumCircuit(1)
>>> for x_i in x:
... circuit.rx(x_i, 0)
>>> circuit.parameters
ParameterView([
ParameterVectorElement(x[0]), ParameterVectorElement(x[1]),
ParameterVectorElement(x[2]), ParameterVectorElement(x[3]),
..., ParameterVectorElement(x[11])
])
```
**Returns**
The sorted [`Parameter`](qiskit.circuit.Parameter "qiskit.circuit.Parameter") objects in the circuit.
</Attribute>
### prefix

View File

@ -66,7 +66,17 @@ python_api_name: qiskit.circuit.library.QAOAAnsatz
### data
<Attribute id="qiskit.circuit.library.QAOAAnsatz.data" />
<Attribute id="qiskit.circuit.library.QAOAAnsatz.data">
The circuit data (instructions and context).
**Returns**
a list-like object containing the [`CircuitInstruction`](qiskit.circuit.CircuitInstruction "qiskit.circuit.CircuitInstruction")s for each instruction.
**Return type**
QuantumCircuitData
</Attribute>
### entanglement
@ -214,7 +224,9 @@ python_api_name: qiskit.circuit.library.QAOAAnsatz
### num\_parameters
<Attribute id="qiskit.circuit.library.QAOAAnsatz.num_parameters" />
<Attribute id="qiskit.circuit.library.QAOAAnsatz.num_parameters">
The number of parameter objects in the circuit.
</Attribute>
### num\_parameters\_settable
@ -314,7 +326,61 @@ python_api_name: qiskit.circuit.library.QAOAAnsatz
### parameters
<Attribute id="qiskit.circuit.library.QAOAAnsatz.parameters" />
<Attribute id="qiskit.circuit.library.QAOAAnsatz.parameters">
The parameters defined in the circuit.
This attribute returns the [`Parameter`](qiskit.circuit.Parameter "qiskit.circuit.Parameter") objects in the circuit sorted alphabetically. Note that parameters instantiated with a [`ParameterVector`](qiskit.circuit.ParameterVector "qiskit.circuit.ParameterVector") are still sorted numerically.
**Examples**
The snippet below shows that insertion order of parameters does not matter.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter
>>> a, b, elephant = Parameter("a"), Parameter("b"), Parameter("elephant")
>>> circuit = QuantumCircuit(1)
>>> circuit.rx(b, 0)
>>> circuit.rz(elephant, 0)
>>> circuit.ry(a, 0)
>>> circuit.parameters # sorted alphabetically!
ParameterView([Parameter(a), Parameter(b), Parameter(elephant)])
```
Bear in mind that alphabetical sorting might be unintuitive when it comes to numbers. The literal “10” comes before “2” in strict alphabetical sorting.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter
>>> angles = [Parameter("angle_1"), Parameter("angle_2"), Parameter("angle_10")]
>>> circuit = QuantumCircuit(1)
>>> circuit.u(*angles, 0)
>>> circuit.draw()
┌─────────────────────────────┐
q: ┤ U(angle_1,angle_2,angle_10) ├
└─────────────────────────────┘
>>> circuit.parameters
ParameterView([Parameter(angle_1), Parameter(angle_10), Parameter(angle_2)])
```
To respect numerical sorting, a [`ParameterVector`](qiskit.circuit.ParameterVector "qiskit.circuit.ParameterVector") can be used.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter, ParameterVector
>>> x = ParameterVector("x", 12)
>>> circuit = QuantumCircuit(1)
>>> for x_i in x:
... circuit.rx(x_i, 0)
>>> circuit.parameters
ParameterView([
ParameterVectorElement(x[0]), ParameterVectorElement(x[1]),
ParameterVectorElement(x[2]), ParameterVectorElement(x[3]),
..., ParameterVectorElement(x[11])
])
```
**Returns**
The sorted [`Parameter`](qiskit.circuit.Parameter "qiskit.circuit.Parameter") objects in the circuit.
</Attribute>
### preferred\_init\_points

View File

@ -80,7 +80,17 @@ $$
### data
<Attribute id="qiskit.circuit.library.QFT.data" />
<Attribute id="qiskit.circuit.library.QFT.data">
The circuit data (instructions and context).
**Returns**
a list-like object containing the [`CircuitInstruction`](qiskit.circuit.CircuitInstruction "qiskit.circuit.CircuitInstruction")s for each instruction.
**Return type**
QuantumCircuitData
</Attribute>
### do\_swaps
@ -168,7 +178,9 @@ $$
### num\_parameters
<Attribute id="qiskit.circuit.library.QFT.num_parameters" />
<Attribute id="qiskit.circuit.library.QFT.num_parameters">
The number of parameter objects in the circuit.
</Attribute>
### num\_qubits
@ -206,7 +218,61 @@ $$
### parameters
<Attribute id="qiskit.circuit.library.QFT.parameters" />
<Attribute id="qiskit.circuit.library.QFT.parameters">
The parameters defined in the circuit.
This attribute returns the [`Parameter`](qiskit.circuit.Parameter "qiskit.circuit.Parameter") objects in the circuit sorted alphabetically. Note that parameters instantiated with a [`ParameterVector`](qiskit.circuit.ParameterVector "qiskit.circuit.ParameterVector") are still sorted numerically.
**Examples**
The snippet below shows that insertion order of parameters does not matter.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter
>>> a, b, elephant = Parameter("a"), Parameter("b"), Parameter("elephant")
>>> circuit = QuantumCircuit(1)
>>> circuit.rx(b, 0)
>>> circuit.rz(elephant, 0)
>>> circuit.ry(a, 0)
>>> circuit.parameters # sorted alphabetically!
ParameterView([Parameter(a), Parameter(b), Parameter(elephant)])
```
Bear in mind that alphabetical sorting might be unintuitive when it comes to numbers. The literal “10” comes before “2” in strict alphabetical sorting.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter
>>> angles = [Parameter("angle_1"), Parameter("angle_2"), Parameter("angle_10")]
>>> circuit = QuantumCircuit(1)
>>> circuit.u(*angles, 0)
>>> circuit.draw()
┌─────────────────────────────┐
q: ┤ U(angle_1,angle_2,angle_10) ├
└─────────────────────────────┘
>>> circuit.parameters
ParameterView([Parameter(angle_1), Parameter(angle_10), Parameter(angle_2)])
```
To respect numerical sorting, a [`ParameterVector`](qiskit.circuit.ParameterVector "qiskit.circuit.ParameterVector") can be used.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter, ParameterVector
>>> x = ParameterVector("x", 12)
>>> circuit = QuantumCircuit(1)
>>> for x_i in x:
... circuit.rx(x_i, 0)
>>> circuit.parameters
ParameterView([
ParameterVectorElement(x[0]), ParameterVectorElement(x[1]),
ParameterVectorElement(x[2]), ParameterVectorElement(x[3]),
..., ParameterVectorElement(x[11])
])
```
**Returns**
The sorted [`Parameter`](qiskit.circuit.Parameter "qiskit.circuit.Parameter") objects in the circuit.
</Attribute>
### prefix

View File

@ -48,7 +48,7 @@ $$
> $$
>
> $$
> R_{XX}(\theta = \pi) = i X \otimes X
> R_{XX}(\theta = \pi) = -i X \otimes X
> $$
>
> $$

View File

@ -48,7 +48,7 @@ $$
> $$
>
> $$
> R_{YY}(\theta = \pi) = i Y \otimes Y
> R_{YY}(\theta = \pi) = -i Y \otimes Y
> $$
>
> $$

View File

@ -88,7 +88,7 @@ $$
> $$
>
> $$
> R_{ZX}(\theta = \pi) = -i Z \otimes X
> R_{ZX}(\theta = \pi) = -i X \otimes Z
> $$
>
> $$

View File

@ -136,7 +136,17 @@ python_api_name: qiskit.circuit.library.RealAmplitudes
### data
<Attribute id="qiskit.circuit.library.RealAmplitudes.data" />
<Attribute id="qiskit.circuit.library.RealAmplitudes.data">
The circuit data (instructions and context).
**Returns**
a list-like object containing the [`CircuitInstruction`](qiskit.circuit.CircuitInstruction "qiskit.circuit.CircuitInstruction")s for each instruction.
**Return type**
QuantumCircuitData
</Attribute>
### entanglement
@ -260,7 +270,9 @@ python_api_name: qiskit.circuit.library.RealAmplitudes
### num\_parameters
<Attribute id="qiskit.circuit.library.RealAmplitudes.num_parameters" />
<Attribute id="qiskit.circuit.library.RealAmplitudes.num_parameters">
The number of parameter objects in the circuit.
</Attribute>
### num\_parameters\_settable
@ -350,7 +362,61 @@ python_api_name: qiskit.circuit.library.RealAmplitudes
### parameters
<Attribute id="qiskit.circuit.library.RealAmplitudes.parameters" />
<Attribute id="qiskit.circuit.library.RealAmplitudes.parameters">
The parameters defined in the circuit.
This attribute returns the [`Parameter`](qiskit.circuit.Parameter "qiskit.circuit.Parameter") objects in the circuit sorted alphabetically. Note that parameters instantiated with a [`ParameterVector`](qiskit.circuit.ParameterVector "qiskit.circuit.ParameterVector") are still sorted numerically.
**Examples**
The snippet below shows that insertion order of parameters does not matter.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter
>>> a, b, elephant = Parameter("a"), Parameter("b"), Parameter("elephant")
>>> circuit = QuantumCircuit(1)
>>> circuit.rx(b, 0)
>>> circuit.rz(elephant, 0)
>>> circuit.ry(a, 0)
>>> circuit.parameters # sorted alphabetically!
ParameterView([Parameter(a), Parameter(b), Parameter(elephant)])
```
Bear in mind that alphabetical sorting might be unintuitive when it comes to numbers. The literal “10” comes before “2” in strict alphabetical sorting.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter
>>> angles = [Parameter("angle_1"), Parameter("angle_2"), Parameter("angle_10")]
>>> circuit = QuantumCircuit(1)
>>> circuit.u(*angles, 0)
>>> circuit.draw()
┌─────────────────────────────┐
q: ┤ U(angle_1,angle_2,angle_10) ├
└─────────────────────────────┘
>>> circuit.parameters
ParameterView([Parameter(angle_1), Parameter(angle_10), Parameter(angle_2)])
```
To respect numerical sorting, a [`ParameterVector`](qiskit.circuit.ParameterVector "qiskit.circuit.ParameterVector") can be used.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter, ParameterVector
>>> x = ParameterVector("x", 12)
>>> circuit = QuantumCircuit(1)
>>> for x_i in x:
... circuit.rx(x_i, 0)
>>> circuit.parameters
ParameterView([
ParameterVectorElement(x[0]), ParameterVectorElement(x[1]),
ParameterVectorElement(x[2]), ParameterVectorElement(x[3]),
..., ParameterVectorElement(x[11])
])
```
**Returns**
The sorted [`Parameter`](qiskit.circuit.Parameter "qiskit.circuit.Parameter") objects in the circuit.
</Attribute>
### preferred\_init\_points

View File

@ -148,7 +148,17 @@ python_api_name: qiskit.circuit.library.TwoLocal
### data
<Attribute id="qiskit.circuit.library.TwoLocal.data" />
<Attribute id="qiskit.circuit.library.TwoLocal.data">
The circuit data (instructions and context).
**Returns**
a list-like object containing the [`CircuitInstruction`](qiskit.circuit.CircuitInstruction "qiskit.circuit.CircuitInstruction")s for each instruction.
**Return type**
QuantumCircuitData
</Attribute>
### entanglement
@ -272,7 +282,9 @@ python_api_name: qiskit.circuit.library.TwoLocal
### num\_parameters
<Attribute id="qiskit.circuit.library.TwoLocal.num_parameters" />
<Attribute id="qiskit.circuit.library.TwoLocal.num_parameters">
The number of parameter objects in the circuit.
</Attribute>
### num\_parameters\_settable
@ -362,7 +374,61 @@ python_api_name: qiskit.circuit.library.TwoLocal
### parameters
<Attribute id="qiskit.circuit.library.TwoLocal.parameters" />
<Attribute id="qiskit.circuit.library.TwoLocal.parameters">
The parameters defined in the circuit.
This attribute returns the [`Parameter`](qiskit.circuit.Parameter "qiskit.circuit.Parameter") objects in the circuit sorted alphabetically. Note that parameters instantiated with a [`ParameterVector`](qiskit.circuit.ParameterVector "qiskit.circuit.ParameterVector") are still sorted numerically.
**Examples**
The snippet below shows that insertion order of parameters does not matter.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter
>>> a, b, elephant = Parameter("a"), Parameter("b"), Parameter("elephant")
>>> circuit = QuantumCircuit(1)
>>> circuit.rx(b, 0)
>>> circuit.rz(elephant, 0)
>>> circuit.ry(a, 0)
>>> circuit.parameters # sorted alphabetically!
ParameterView([Parameter(a), Parameter(b), Parameter(elephant)])
```
Bear in mind that alphabetical sorting might be unintuitive when it comes to numbers. The literal “10” comes before “2” in strict alphabetical sorting.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter
>>> angles = [Parameter("angle_1"), Parameter("angle_2"), Parameter("angle_10")]
>>> circuit = QuantumCircuit(1)
>>> circuit.u(*angles, 0)
>>> circuit.draw()
┌─────────────────────────────┐
q: ┤ U(angle_1,angle_2,angle_10) ├
└─────────────────────────────┘
>>> circuit.parameters
ParameterView([Parameter(angle_1), Parameter(angle_10), Parameter(angle_2)])
```
To respect numerical sorting, a [`ParameterVector`](qiskit.circuit.ParameterVector "qiskit.circuit.ParameterVector") can be used.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter, ParameterVector
>>> x = ParameterVector("x", 12)
>>> circuit = QuantumCircuit(1)
>>> for x_i in x:
... circuit.rx(x_i, 0)
>>> circuit.parameters
ParameterView([
ParameterVectorElement(x[0]), ParameterVectorElement(x[1]),
ParameterVectorElement(x[2]), ParameterVectorElement(x[3]),
..., ParameterVectorElement(x[11])
])
```
**Returns**
The sorted [`Parameter`](qiskit.circuit.Parameter "qiskit.circuit.Parameter") objects in the circuit.
</Attribute>
### preferred\_init\_points

View File

@ -86,7 +86,17 @@ $$
### data
<Attribute id="qiskit.circuit.library.WeightedAdder.data" />
<Attribute id="qiskit.circuit.library.WeightedAdder.data">
The circuit data (instructions and context).
**Returns**
a list-like object containing the [`CircuitInstruction`](qiskit.circuit.CircuitInstruction "qiskit.circuit.CircuitInstruction")s for each instruction.
**Return type**
QuantumCircuitData
</Attribute>
### global\_phase
@ -178,7 +188,9 @@ $$
### num\_parameters
<Attribute id="qiskit.circuit.library.WeightedAdder.num_parameters" />
<Attribute id="qiskit.circuit.library.WeightedAdder.num_parameters">
The number of parameter objects in the circuit.
</Attribute>
### num\_qubits
@ -232,7 +244,61 @@ $$
### parameters
<Attribute id="qiskit.circuit.library.WeightedAdder.parameters" />
<Attribute id="qiskit.circuit.library.WeightedAdder.parameters">
The parameters defined in the circuit.
This attribute returns the [`Parameter`](qiskit.circuit.Parameter "qiskit.circuit.Parameter") objects in the circuit sorted alphabetically. Note that parameters instantiated with a [`ParameterVector`](qiskit.circuit.ParameterVector "qiskit.circuit.ParameterVector") are still sorted numerically.
**Examples**
The snippet below shows that insertion order of parameters does not matter.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter
>>> a, b, elephant = Parameter("a"), Parameter("b"), Parameter("elephant")
>>> circuit = QuantumCircuit(1)
>>> circuit.rx(b, 0)
>>> circuit.rz(elephant, 0)
>>> circuit.ry(a, 0)
>>> circuit.parameters # sorted alphabetically!
ParameterView([Parameter(a), Parameter(b), Parameter(elephant)])
```
Bear in mind that alphabetical sorting might be unintuitive when it comes to numbers. The literal “10” comes before “2” in strict alphabetical sorting.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter
>>> angles = [Parameter("angle_1"), Parameter("angle_2"), Parameter("angle_10")]
>>> circuit = QuantumCircuit(1)
>>> circuit.u(*angles, 0)
>>> circuit.draw()
┌─────────────────────────────┐
q: ┤ U(angle_1,angle_2,angle_10) ├
└─────────────────────────────┘
>>> circuit.parameters
ParameterView([Parameter(angle_1), Parameter(angle_10), Parameter(angle_2)])
```
To respect numerical sorting, a [`ParameterVector`](qiskit.circuit.ParameterVector "qiskit.circuit.ParameterVector") can be used.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter, ParameterVector
>>> x = ParameterVector("x", 12)
>>> circuit = QuantumCircuit(1)
>>> for x_i in x:
... circuit.rx(x_i, 0)
>>> circuit.parameters
ParameterView([
ParameterVectorElement(x[0]), ParameterVectorElement(x[1]),
ParameterVectorElement(x[2]), ParameterVectorElement(x[3]),
..., ParameterVectorElement(x[11])
])
```
**Returns**
The sorted [`Parameter`](qiskit.circuit.Parameter "qiskit.circuit.Parameter") objects in the circuit.
</Attribute>
### prefix

View File

@ -8,7 +8,7 @@ python_api_name: qiskit.circuit.library.ZFeatureMap
# ZFeatureMap
<Class id="qiskit.circuit.library.ZFeatureMap" isDedicatedPage={true} github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/circuit/library/data_preparation/z_feature_map.py#L21-L104" signature="qiskit.circuit.library.ZFeatureMap(feature_dimension, reps=2, data_map_func=None, parameter_prefix='x', insert_barriers=False, name='ZFeatureMap')" modifiers="class">
<Class id="qiskit.circuit.library.ZFeatureMap" isDedicatedPage={true} github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/circuit/library/data_preparation/z_feature_map.py#L21-L106" signature="qiskit.circuit.library.ZFeatureMap(feature_dimension, reps=2, data_map_func=None, parameter_prefix='x', insert_barriers=False, name='ZFeatureMap')" modifiers="class">
Bases: [`PauliFeatureMap`](qiskit.circuit.library.PauliFeatureMap "qiskit.circuit.library.data_preparation.pauli_feature_map.PauliFeatureMap")
The first order Pauli Z-evolution circuit.
@ -16,13 +16,13 @@ python_api_name: qiskit.circuit.library.ZFeatureMap
On 3 qubits and with 2 repetitions the circuit is represented by:
```python
┌───┐┌─────────────┐┌───┐┌─────────────┐
┤ H ├┤ U1(2.0*x[0]) ├┤ H ├┤ U1(2.0*x[0]) ├
├───┤├─────────────┤├───┤├─────────────┤
┤ H ├┤ U1(2.0*x[1]) ├┤ H ├┤ U1(2.0*x[1]) ├
├───┤├─────────────┤├───┤├─────────────┤
┤ H ├┤ U1(2.0*x[2]) ├┤ H ├┤ U1(2.0*x[2]) ├
└───┘└─────────────┘└───┘└─────────────┘
┌───┐┌─────────────┐┌───┐┌─────────────┐
┤ H ├┤ P(2.0*x[0]) ├┤ H ├┤ P(2.0*x[0]) ├
├───┤├─────────────┤├───┤├─────────────┤
┤ H ├┤ P(2.0*x[1]) ├┤ H ├┤ P(2.0*x[1]) ├
├───┤├─────────────┤├───┤├─────────────┤
┤ H ├┤ P(2.0*x[2]) ├┤ H ├┤ P(2.0*x[2]) ├
└───┘└─────────────┘└───┘└─────────────┘
```
This is a sub-class of [`PauliFeatureMap`](qiskit.circuit.library.PauliFeatureMap "qiskit.circuit.library.PauliFeatureMap") where the Pauli strings are fixed as \[Z]. As a result the first order expansion will be a circuit without entangling gates.
@ -30,40 +30,42 @@ python_api_name: qiskit.circuit.library.ZFeatureMap
**Examples**
```python
>>> from qiskit.circuit.library import ZFeatureMap
>>> prep = ZFeatureMap(3, reps=3, insert_barriers=True)
>>> print(prep)
┌───┐ ░ ┌─────────────┐ ░ ┌───┐ ░ ┌─────────────┐ ░ ┌───┐ ░ ┌─────────────┐
q_0: ┤ H ├─░─┤ U1(2.0*x[0]) ├─░─┤ H ├─░─┤ U1(2.0*x[0]) ├─░─┤ H ├─░─┤ U1(2.0*x[0]) ├
├───┤ ░ ├─────────────┤ ░ ├───┤ ░ ├─────────────┤ ░ ├───┤ ░ ├─────────────┤
q_1: ┤ H ├─░─┤ U1(2.0*x[1]) ├─░─┤ H ├─░─┤ U1(2.0*x[1]) ├─░─┤ H ├─░─┤ U1(2.0*x[1]) ├
├───┤ ░ ├─────────────┤ ░ ├───┤ ░ ├─────────────┤ ░ ├───┤ ░ ├─────────────┤
q_2: ┤ H ├─░─┤ U1(2.0*x[2]) ├─░─┤ H ├─░─┤ U1(2.0*x[2]) ├─░─┤ H ├─░─┤ U1(2.0*x[2]) ├
└───┘ ░ └─────────────┘ ░ └───┘ ░ └─────────────┘ ░ └───┘ ░ └─────────────┘
>>> print(prep.decompose())
┌───┐ ░ ┌─────────────┐ ░ ┌───┐ ░ ┌─────────────┐ ░ ┌───┐ ░ ┌─────────────┐
q_0: ┤ H ├─░─┤ P(2.0*x[0]) ├─░─┤ H ├─░─┤ P(2.0*x[0]) ├─░─┤ H ├─░─┤ P(2.0*x[0]) ├
├───┤ ░ ├─────────────┤ ░ ├───┤ ░ ├─────────────┤ ░ ├───┤ ░ ├─────────────┤
q_1: ┤ H ├─░─┤ P(2.0*x[1]) ├─░─┤ H ├─░─┤ P(2.0*x[1]) ├─░─┤ H ├─░─┤ P(2.0*x[1]) ├
├───┤ ░ ├─────────────┤ ░ ├───┤ ░ ├─────────────┤ ░ ├───┤ ░ ├─────────────┤
q_2: ┤ H ├─░─┤ P(2.0*x[2]) ├─░─┤ H ├─░─┤ P(2.0*x[2]) ├─░─┤ H ├─░─┤ P(2.0*x[2]) ├
└───┘ ░ └─────────────┘ ░ └───┘ ░ └─────────────┘ ░ └───┘ ░ └─────────────┘
```
```python
>>> data_map = lambda x: x[0]*x[0] + 1 # note: input is an array
>>> prep = ZFeatureMap(3, reps=1, data_map_func=data_map)
>>> print(prep)
┌───┐┌──────────────────────
q_0: ┤ H ├┤ U1(2.0*x[0]**2 + 2.0) ├
├───┤├──────────────────────
q_1: ┤ H ├┤ U1(2.0*x[1]**2 + 2.0) ├
├───┤├──────────────────────
q_2: ┤ H ├┤ U1(2.0*x[2]**2 + 2.0) ├
└───┘└──────────────────────
>>> print(prep.decompose())
┌───┐┌──────────────────────┐
q_0: ┤ H ├┤ P(2.0*x[0]**2 + 2.0) ├
├───┤├──────────────────────┤
q_1: ┤ H ├┤ P(2.0*x[1]**2 + 2.0) ├
├───┤├──────────────────────┤
q_2: ┤ H ├┤ P(2.0*x[2]**2 + 2.0) ├
└───┘└──────────────────────┘
```
```python
>>> classifier = ZFeatureMap(3, reps=1) + RY(3, reps=1)
>>> print(classifier)
┌───┐┌──────────────┐┌──────────┐ ┌──────────┐
q_0: ┤ H ├┤ U1(2.0*x[0]) ├┤ RY(θ[0]) ├─■──■─┤ RY(θ[3]) ├────────────
├───┤├──────────────┤├──────────┤ │ │ └──────────┘┌──────────┐
q_1: ┤ H ├┤ U1(2.0*x[1]) ├┤ RY(θ[1]) ├─■──┼──────■──────┤ RY(θ[4]) ├
├───┤├──────────────┤├──────────┤ │ │ ├──────────┤
q_2: ┤ H ├┤ U1(2.0*x[2]) ├┤ RY(θ[2]) ├────■──────■──────┤ RY(θ[5]) ├
└───┘└──────────────┘└──────────┘ └──────────┘
>>> from qiskit.circuit.library import RealAmplitudes
>>> classifier = ZFeatureMap(3, reps=1).compose(RealAmplitudes(3, reps=1))
>>> print(classifier.decompose())
┌───┐┌─────────────┐┌──────────┐ ┌──────────┐
q_0: ┤ H ├┤ P(2.0*x[0]) ├┤ RY(θ[0]) ├─■──■─┤ RY(θ[3]) ├────────────
├───┤├─────────────┤├──────────┤ │ │ └──────────┘┌──────────┐
q_1: ┤ H ├┤ P(2.0*x[1]) ├┤ RY(θ[1]) ├─■──┼──────■──────┤ RY(θ[4]) ├
├───┤├─────────────┤├──────────┤ │ │ ├──────────┤
q_2: ┤ H ├┤ P(2.0*x[2]) ├┤ RY(θ[2]) ├────■──────■──────┤ RY(θ[5]) ├
└───┘└─────────────┘└──────────┘ └──────────┘
```
Create a new first-order Pauli-Z expansion circuit.
@ -110,7 +112,17 @@ python_api_name: qiskit.circuit.library.ZFeatureMap
### data
<Attribute id="qiskit.circuit.library.ZFeatureMap.data" />
<Attribute id="qiskit.circuit.library.ZFeatureMap.data">
The circuit data (instructions and context).
**Returns**
a list-like object containing the [`CircuitInstruction`](qiskit.circuit.CircuitInstruction "qiskit.circuit.CircuitInstruction")s for each instruction.
**Return type**
QuantumCircuitData
</Attribute>
### entanglement
@ -124,7 +136,13 @@ python_api_name: qiskit.circuit.library.ZFeatureMap
### entanglement\_blocks
<Attribute id="qiskit.circuit.library.ZFeatureMap.entanglement_blocks" />
<Attribute id="qiskit.circuit.library.ZFeatureMap.entanglement_blocks">
The blocks in the entanglement layers.
**Returns**
The blocks in the entanglement layers.
</Attribute>
### feature\_dimension
@ -238,7 +256,9 @@ python_api_name: qiskit.circuit.library.ZFeatureMap
### num\_parameters
<Attribute id="qiskit.circuit.library.ZFeatureMap.num_parameters" />
<Attribute id="qiskit.circuit.library.ZFeatureMap.num_parameters">
The number of parameter objects in the circuit.
</Attribute>
### num\_parameters\_settable
@ -318,7 +338,61 @@ python_api_name: qiskit.circuit.library.ZFeatureMap
### parameters
<Attribute id="qiskit.circuit.library.ZFeatureMap.parameters" />
<Attribute id="qiskit.circuit.library.ZFeatureMap.parameters">
The parameters defined in the circuit.
This attribute returns the [`Parameter`](qiskit.circuit.Parameter "qiskit.circuit.Parameter") objects in the circuit sorted alphabetically. Note that parameters instantiated with a [`ParameterVector`](qiskit.circuit.ParameterVector "qiskit.circuit.ParameterVector") are still sorted numerically.
**Examples**
The snippet below shows that insertion order of parameters does not matter.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter
>>> a, b, elephant = Parameter("a"), Parameter("b"), Parameter("elephant")
>>> circuit = QuantumCircuit(1)
>>> circuit.rx(b, 0)
>>> circuit.rz(elephant, 0)
>>> circuit.ry(a, 0)
>>> circuit.parameters # sorted alphabetically!
ParameterView([Parameter(a), Parameter(b), Parameter(elephant)])
```
Bear in mind that alphabetical sorting might be unintuitive when it comes to numbers. The literal “10” comes before “2” in strict alphabetical sorting.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter
>>> angles = [Parameter("angle_1"), Parameter("angle_2"), Parameter("angle_10")]
>>> circuit = QuantumCircuit(1)
>>> circuit.u(*angles, 0)
>>> circuit.draw()
┌─────────────────────────────┐
q: ┤ U(angle_1,angle_2,angle_10) ├
└─────────────────────────────┘
>>> circuit.parameters
ParameterView([Parameter(angle_1), Parameter(angle_10), Parameter(angle_2)])
```
To respect numerical sorting, a [`ParameterVector`](qiskit.circuit.ParameterVector "qiskit.circuit.ParameterVector") can be used.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter, ParameterVector
>>> x = ParameterVector("x", 12)
>>> circuit = QuantumCircuit(1)
>>> for x_i in x:
... circuit.rx(x_i, 0)
>>> circuit.parameters
ParameterView([
ParameterVectorElement(x[0]), ParameterVectorElement(x[1]),
ParameterVectorElement(x[2]), ParameterVectorElement(x[3]),
..., ParameterVectorElement(x[11])
])
```
**Returns**
The sorted [`Parameter`](qiskit.circuit.Parameter "qiskit.circuit.Parameter") objects in the circuit.
</Attribute>
### paulis

View File

@ -8,7 +8,7 @@ python_api_name: qiskit.circuit.library.ZZFeatureMap
# ZZFeatureMap
<Class id="qiskit.circuit.library.ZZFeatureMap" isDedicatedPage={true} github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/circuit/library/data_preparation/zz_feature_map.py#L20-L114" signature="qiskit.circuit.library.ZZFeatureMap(feature_dimension, reps=2, entanglement='full', data_map_func=None, parameter_prefix='x', insert_barriers=False, name='ZZFeatureMap')" modifiers="class">
<Class id="qiskit.circuit.library.ZZFeatureMap" isDedicatedPage={true} github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/circuit/library/data_preparation/zz_feature_map.py#L20-L136" signature="qiskit.circuit.library.ZZFeatureMap(feature_dimension, reps=2, entanglement='full', data_map_func=None, parameter_prefix='x', insert_barriers=False, name='ZZFeatureMap')" modifiers="class">
Bases: [`PauliFeatureMap`](qiskit.circuit.library.PauliFeatureMap "qiskit.circuit.library.data_preparation.pauli_feature_map.PauliFeatureMap")
Second-order Pauli-Z evolution circuit.
@ -16,36 +16,48 @@ python_api_name: qiskit.circuit.library.ZZFeatureMap
For 3 qubits and 1 repetition and linear entanglement the circuit is represented by:
```python
┌───┐┌────────────────
┤ H ├┤ U1(2.0*φ(x[0])) ├──■──────────────────────────────────────────────────────────────
├───┤├────────────────┤┌─┴─┐┌─────────────────────┐┌─┴─┐
┤ H ├┤ U1(2.0*φ(x[1])) ├┤ X ├┤ U1(2.0*φ(x[0],x[1])) ├┤ X ├──■────────────────────────────■──
├───┤├────────────────┤└───┘└─────────────────────┘└───┘┌─┴─┐┌─────────────────────┐┌─┴─┐
┤ H ├┤ U1(2.0*φ(x[2])) ├──────────────────────────────────┤ X ├┤ U1(2.0*φ(x[1],x[2])) ├┤ X ├
└───┘└──────────────── └───┘└─────────────────────┘└───┘
┌───┐┌────────────────┐
┤ H ├┤ P(2.0*φ(x[0])) ├──■───────────────────────────■───────────────────────────────────
├───┤├────────────────┤┌─┴─┐┌─────────────────────┐┌─┴─┐
┤ H ├┤ P(2.0*φ(x[1])) ├┤ X ├┤ P(2.0*φ(x[0],x[1])) ├┤ X ├──■───────────────────────────■──
├───┤├────────────────┤└───┘└─────────────────────┘└───┘┌─┴─┐┌─────────────────────┐┌─┴─┐
┤ H ├┤ P(2.0*φ(x[2])) ├─────────────────────────────────┤ X ├┤ P(2.0*φ(x[1],x[2])) ├┤ X ├
└───┘└────────────────┘ └───┘└─────────────────────┘└───┘
```
where $\varphi$ is a classical non-linear function, which defaults to $\varphi(x) = x$ if and $\varphi(x,y) = (\pi - x)(\pi - y)$.
**Examples**
Examples:
```python
>>> from qiskit.circuit.library import ZZFeatureMap
>>> prep = ZZFeatureMap(2, reps=1)
>>> print(prep)
┌───┐┌──────────────┐
q_0: ┤ H ├┤ U1(2.0*x[0]) ├──■───────────────────────────────────────■──
├───┤├──────────────┤┌─┴─┐┌─────────────────────────────────┐┌─┴─┐
q_1: ┤ H ├┤ U1(2.0*x[1]) ├┤ X ├┤ U1(2.0*(pi - x[0])*(pi - x[1])) ├┤ X ├
└───┘└──────────────┘└───┘└─────────────────────────────────┘└───┘
from qiskit.circuit.library import ZZFeatureMap
prep = ZZFeatureMap(2, reps=1)
print(prep.decompose())
```
```python
┌───┐┌─────────────┐
q_0: ┤ H ├┤ P(2.0*x[0]) ├──■──────────────────────────────────────■──
├───┤├─────────────┤┌─┴─┐┌────────────────────────────────┐┌─┴─┐
q_1: ┤ H ├┤ P(2.0*x[1]) ├┤ X ├┤ P(2.0*(pi - x[0])*(pi - x[1])) ├┤ X ├
└───┘└─────────────┘└───┘└────────────────────────────────┘└───┘
```
```python
from qiskit.circuit.library import EfficientSU2
classifier = ZZFeatureMap(3).compose(EfficientSU2(3))
classifier.num_parameters
```
```python
27
```
```python
classifier.parameters # 'x' for the data preparation, 'θ' for the SU2 parameters
```
```python
>>> from qiskit.circuit.library import EfficientSU2
>>> classifier = ZZFeatureMap(3) + EfficientSU2(3)
>>> classifier.num_parameters
15
>>> classifier.parameters # 'x' for the data preparation, 'θ' for the SU2 parameters
ParameterView([
ParameterVectorElement(x[0]), ParameterVectorElement(x[1]),
ParameterVectorElement(x[2]), ParameterVectorElement(θ[0]),
@ -62,7 +74,13 @@ python_api_name: qiskit.circuit.library.ZZFeatureMap
ParameterVectorElement(θ[21]), ParameterVectorElement(θ[22]),
ParameterVectorElement(θ[23])
])
>>> classifier.count_ops()
```
```python
classifier.count_ops()
```
```python
OrderedDict([('ZZFeatureMap', 1), ('EfficientSU2', 1)])
```
@ -115,7 +133,17 @@ python_api_name: qiskit.circuit.library.ZZFeatureMap
### data
<Attribute id="qiskit.circuit.library.ZZFeatureMap.data" />
<Attribute id="qiskit.circuit.library.ZZFeatureMap.data">
The circuit data (instructions and context).
**Returns**
a list-like object containing the [`CircuitInstruction`](qiskit.circuit.CircuitInstruction "qiskit.circuit.CircuitInstruction")s for each instruction.
**Return type**
QuantumCircuitData
</Attribute>
### entanglement
@ -129,7 +157,13 @@ python_api_name: qiskit.circuit.library.ZZFeatureMap
### entanglement\_blocks
<Attribute id="qiskit.circuit.library.ZZFeatureMap.entanglement_blocks" />
<Attribute id="qiskit.circuit.library.ZZFeatureMap.entanglement_blocks">
The blocks in the entanglement layers.
**Returns**
The blocks in the entanglement layers.
</Attribute>
### feature\_dimension
@ -243,7 +277,9 @@ python_api_name: qiskit.circuit.library.ZZFeatureMap
### num\_parameters
<Attribute id="qiskit.circuit.library.ZZFeatureMap.num_parameters" />
<Attribute id="qiskit.circuit.library.ZZFeatureMap.num_parameters">
The number of parameter objects in the circuit.
</Attribute>
### num\_parameters\_settable
@ -323,7 +359,61 @@ python_api_name: qiskit.circuit.library.ZZFeatureMap
### parameters
<Attribute id="qiskit.circuit.library.ZZFeatureMap.parameters" />
<Attribute id="qiskit.circuit.library.ZZFeatureMap.parameters">
The parameters defined in the circuit.
This attribute returns the [`Parameter`](qiskit.circuit.Parameter "qiskit.circuit.Parameter") objects in the circuit sorted alphabetically. Note that parameters instantiated with a [`ParameterVector`](qiskit.circuit.ParameterVector "qiskit.circuit.ParameterVector") are still sorted numerically.
**Examples**
The snippet below shows that insertion order of parameters does not matter.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter
>>> a, b, elephant = Parameter("a"), Parameter("b"), Parameter("elephant")
>>> circuit = QuantumCircuit(1)
>>> circuit.rx(b, 0)
>>> circuit.rz(elephant, 0)
>>> circuit.ry(a, 0)
>>> circuit.parameters # sorted alphabetically!
ParameterView([Parameter(a), Parameter(b), Parameter(elephant)])
```
Bear in mind that alphabetical sorting might be unintuitive when it comes to numbers. The literal “10” comes before “2” in strict alphabetical sorting.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter
>>> angles = [Parameter("angle_1"), Parameter("angle_2"), Parameter("angle_10")]
>>> circuit = QuantumCircuit(1)
>>> circuit.u(*angles, 0)
>>> circuit.draw()
┌─────────────────────────────┐
q: ┤ U(angle_1,angle_2,angle_10) ├
└─────────────────────────────┘
>>> circuit.parameters
ParameterView([Parameter(angle_1), Parameter(angle_10), Parameter(angle_2)])
```
To respect numerical sorting, a [`ParameterVector`](qiskit.circuit.ParameterVector "qiskit.circuit.ParameterVector") can be used.
```python
>>> from qiskit.circuit import QuantumCircuit, Parameter, ParameterVector
>>> x = ParameterVector("x", 12)
>>> circuit = QuantumCircuit(1)
>>> for x_i in x:
... circuit.rx(x_i, 0)
>>> circuit.parameters
ParameterView([
ParameterVectorElement(x[0]), ParameterVectorElement(x[1]),
ParameterVectorElement(x[2]), ParameterVectorElement(x[3]),
..., ParameterVectorElement(x[11])
])
```
**Returns**
The sorted [`Parameter`](qiskit.circuit.Parameter "qiskit.circuit.Parameter") objects in the circuit.
</Attribute>
### paulis

View File

@ -109,7 +109,7 @@ python_api_name: qiskit.visualization.circuit_drawer
**Example**
```python
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
from qiskit import QuantumCircuit
qc = QuantumCircuit(1, 1)
qc.h(0)
qc.measure(0, 0)

View File

@ -55,7 +55,7 @@ and then loading that file will return a list with all the circuits
### load
<Function id="qiskit.qpy.load" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/qpy/interface.py#L210-L341" signature="qiskit.qpy.load(file_obj, metadata_deserializer=None)">
<Function id="qiskit.qpy.load" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/qpy/interface.py#L221-L352" signature="qiskit.qpy.load(file_obj, metadata_deserializer=None)">
Load a QPY binary file
This function is used to load a serialized QPY Qiskit program file and create [`QuantumCircuit`](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit") objects or [`ScheduleBlock`](qiskit.pulse.ScheduleBlock "qiskit.pulse.schedule.ScheduleBlock") objects from its contents. For example:
@ -100,7 +100,7 @@ and then loading that file will return a list with all the circuits
### dump
<Function id="qiskit.qpy.dump" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/qpy/interface.py#L76-L207" signature="qiskit.qpy.dump(programs, file_obj, metadata_serializer=None, use_symengine=True, version=12)">
<Function id="qiskit.qpy.dump" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/qpy/interface.py#L76-L218" signature="qiskit.qpy.dump(programs, file_obj, metadata_serializer=None, use_symengine=True, version=12)">
Write QPY binary data to a file
This function is used to save a circuit to a file for later use or transfer between machines. The QPY format is backwards compatible and can be loaded with future versions of Qiskit.
@ -153,6 +153,10 @@ and then loading that file will return a list with all the circuits
If specified with an older version of QPY the limitations and potential bugs stemming from the QPY format at that version will persist. This should only be used if compatibility with loading the payload with an older version of Qiskit is necessary.
</Admonition>
<Admonition title="Note" type="note">
If serializing a [`QuantumCircuit`](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit") or [`ScheduleBlock`](qiskit.pulse.ScheduleBlock "qiskit.pulse.ScheduleBlock") that contain [`ParameterExpression`](qiskit.circuit.ParameterExpression "qiskit.circuit.ParameterExpression") objects with `version` set low with the intent to load the payload using a historical release of Qiskit, it is safest to set the `use_symengine` flag to `False`. Versions of Qiskit prior to 1.2.4 cannot load QPY files containing `symengine`-serialized [`ParameterExpression`](qiskit.circuit.ParameterExpression "qiskit.circuit.ParameterExpression") objects unless the version of `symengine` used between the loading and generating environments matches.
</Admonition>
**Raises**
* [**QpyError**](#qiskit.qpy.QpyError "qiskit.qpy.QpyError") When multiple data format is mixed in the output.
@ -218,6 +222,15 @@ If a feature being loaded is deprecated in the corresponding qiskit release, QPY
Visible deprecation warning for QPY loading functions without a stable point in the call stack.
</Class>
<Admonition title="Note" type="note">
With versions of Qiskit before 1.2.4, the `use_symengine=True` argument to [`qpy.dump()`](#qiskit.qpy.dump "qiskit.qpy.dump") could cause problems with backwards compatibility if there were [`ParameterExpression`](qiskit.circuit.ParameterExpression "qiskit.circuit.ParameterExpression") objects to serialize. In particular:
* When the loading version of Qiskit is 1.2.4 or greater, QPY files generated with any version of Qiskit >= 0.46.0 can be loaded. If a version of Qiskit between 0.45.0 and 0.45.3 was used to generate the files, and the non-default argument `use_symengine=True` was given to [`qpy.dump()`](#qiskit.qpy.dump "qiskit.qpy.dump"), the file can only be read if the version of `symengine` used in the generating environment was in the 0.11 or 0.13 series. However, if the environment was created during the support window of Qiskit 0.45, it is likely that `symengine==0.9.2` was used.
* When the loading version of Qiskit is between 0.46.0 and 1.2.2 inclusive, the file can only be read if the installed version of `symengine` in the loading environment matches the version used in the generating environment.
To recover a QPY file that fails with `symengine` version-related errors during a call to [`qpy.load()`](#qiskit.qpy.load "qiskit.qpy.load"), first attempt to use Qiskit >= 1.2.4 to load the file. If this still fails, it is likely because Qiskit 0.45.x was used to generate the file with `use_symengine=True`. In this case, use Qiskit 0.45.3 with `symengine==0.9.2` to load the file, and then re-export it to QPY setting `use_symengine=False`. The resulting file can then be loaded by any later version of Qiskit.
</Admonition>
### QPY format version history
If youre planning to load a QPY file between different Qiskit versions knowing which versions were available in a given release are useful. As the QPY is backwards compatible but not forwards compatible you need to ensure a given QPY format version was released in the release youre calling [`load()`](#qiskit.qpy.load "qiskit.qpy.load") with. The following table lists the QPY versions that were supported in every Qiskit (and qiskit-terra prior to Qiskit 1.0.0) release going back to the introduction of QPY in qiskit-terra 0.18.0.

View File

@ -14,16 +14,92 @@ in_page_toc_max_heading_level: 3
<span id="id1" />
## 1.2.4
<span id="relnotes-1-2-4-prelude" />
### Prelude
Qiskit 1.2.4 is a patch release that fixes a QPY problem introduced in the [yanked](https://peps.python.org/pep-0592/) 1.2.3 bugfix release. In 1.2.3, an error would be raised when loading a QPY file that was generated with a different symengine version from the version installed when loading.
<span id="relnotes-1-2-4-bug-fixes" />
### Bug Fixes
* Fixed an issue introduced in the now [yanked](https://peps.python.org/pep-0592/) 1.2.3 bugfix release that would cause an exception with the error message “Qiskit doesnt support loading a symengine payload generated with symengine >= 1.0” to be raised whenever loading a QPY file that was generated with a different symengine version from the version installed when loading. This issue could only occur in 1.2.3.
<span id="relnotes-1-2-3" />
<span id="id2" />
## 1.2.3
<span id="relnotes-1-2-3-prelude" />
<span id="id3" />
### Prelude
Qiskit 1.2.3 is a patch release fixing a problem in QPY that could cause files generated by one Python environment to fail to load in a different Python environment, despite the format supposedly being transferable. This is related to differences in the version of the library `symengine`, which QPY should have protected against.
<span id="relnotes-1-2-3-known-issues" />
### Known Issues
* Versions of Qiskit before 1.2.4 will not be able to load QPY files dumped using [`qpy.dump()`](/api/qiskit/qpy#qiskit.qpy.dump "qiskit.qpy.dump"), even with `version` set appropriately, if:
* there are unbound [`ParameterExpression`](/api/qiskit/qiskit.circuit.ParameterExpression "qiskit.circuit.ParameterExpression") objects in the QPY file,
* the `use_symengine=True` flag was set (which is the default in Qiskit >= 1.0.0) in [`qpy.dump()`](/api/qiskit/qpy#qiskit.qpy.dump "qiskit.qpy.dump"), and
* the version of `symengine` installed in the generating and loading environments are not within the same minor version.
This applies regardless of the version of Qiskit used in the generation (at least up to Qiskit 1.2.4 inclusive).
If you want to maximize compatibility with versions of Qiskit \< 1.2.3, you should set `use_symengine=False`. Versions of Qiskit >= 1.2.3 should not require this.
* QPY files from the Qiskit 0.45 series can, under a very specific and unlikely set of circumstances, fail to load with any newer version of Qiskit, including Qiskit 1.2.4. The criteria are:
* the [`QuantumCircuit`](/api/qiskit/qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit") or [`ScheduleBlock`](/api/qiskit/qiskit.pulse.ScheduleBlock "qiskit.pulse.ScheduleBlock") to be dumped contained unbound [`ParameterExpression`](/api/qiskit/qiskit.circuit.ParameterExpression "qiskit.circuit.ParameterExpression") objects,
* the installed version of `symengine` was in the 0.9 series (which was the most recent release during the support window of Qiskit 0.45), and
* the `use_symengine=True` flag was set (which was *not* the default).
Later versions of Qiskit used during generation are not affected, because they required newer versions than `symengine` 0.9.
In this case, you can recover the QPY file by reloading it with an environment with Qiskit 0.45.3 and `symengine` 0.9.2 installed. Then, use [`qpy.dump()`](/api/qiskit/qpy#qiskit.qpy.dump "qiskit.qpy.dump") with `use_symengine=False` to re-export the file. This will then be readable by any newer version of Qiskit.
<span id="relnotes-1-2-3-upgrade-notes" />
### Upgrade Notes
* The supported versions of [symengine](https://pypi.org/project/symengine/) have been pre-emptively capped at \< 0.14.0 (which is expected to be the next minor version, as of this release of Qiskit). This has been done to protect against a potential incompatibility in [`qpy`](/api/qiskit/qpy#module-qiskit.qpy "qiskit.qpy") when serializing [`ParameterExpression`](/api/qiskit/qiskit.circuit.ParameterExpression "qiskit.circuit.ParameterExpression") objects. The serialization used in [QPY Format](/api/qiskit/qpy#qpy-format) versions 10, 11, and 12 for [`ParameterExpression`](/api/qiskit/qiskit.circuit.ParameterExpression "qiskit.circuit.ParameterExpression") objects is tied to the symengine version used to generate it, and there is the potential for a future symengine release to not be compatible. This upper version cap is to prevent a future release of symengine causing incompatibilities when trying to load QPY files using [`qpy.load()`](/api/qiskit/qpy#qiskit.qpy.load "qiskit.qpy.load").
<span id="relnotes-1-2-3-bug-fixes" />
<span id="id4" />
### Bug Fixes
* Fixed an issue with [`qpy.load()`](/api/qiskit/qpy#qiskit.qpy.load "qiskit.qpy.load") when loading a QPY file containing a [`ParameterExpression`](/api/qiskit/qiskit.circuit.ParameterExpression "qiskit.circuit.ParameterExpression"), if the versions of `symengine` installed in the generating and loading environments were not the same. For example, if a QPY file containing [`ParameterExpression`](/api/qiskit/qiskit.circuit.ParameterExpression "qiskit.circuit.ParameterExpression") objects was generated using Qiskit 1.2.2 with `symengine==0.11.0` installed, Qiskit 1.2.2 with `symengine==0.13.0` installed would be unable to load it.
Previously, an error would have been raised by `symengine` around this version mismatch. This has been worked around for `symengine` 0.11 and 0.13 (there was no 0.12). However, if youre trying to use different versions of `symengine` and there is a mismatch, this version of Qiskit still might not work.
<span id="relnotes-1-2-2" />
<span id="id5" />
## 1.2.2
<span id="relnotes-1-2-2-prelude" />
<span id="id6" />
### Prelude
Qiskit 1.2.2 is a minor bugfix release for the 1.2 series.
<span id="relnotes-1-2-2-bug-fixes" />
<span id="id7" />
### Bug Fixes
* Fixed a bug in the transpiler pass [`ElidePermutations`](/api/qiskit/qiskit.transpiler.passes.ElidePermutations "qiskit.transpiler.passes.ElidePermutations") where the qubit mapping was not updated correctly in the presence of [`PermutationGate`](/api/qiskit/qiskit.circuit.library.PermutationGate "qiskit.circuit.library.PermutationGate")s.
@ -42,13 +118,13 @@ Qiskit 1.2.2 is a minor bugfix release for the 1.2 series.
<span id="relnotes-1-2-1" />
<span id="id2" />
<span id="id8" />
## 1.2.1
<span id="relnotes-1-2-1-prelude" />
<span id="id3" />
<span id="id9" />
### Prelude
@ -56,7 +132,7 @@ Qiskit 1.2.1 is a minor bugfix release for the 1.2 series.
<span id="relnotes-1-2-1-bug-fixes" />
<span id="id4" />
<span id="id10" />
### Bug Fixes
@ -88,13 +164,13 @@ Qiskit 1.2.1 is a minor bugfix release for the 1.2 series.
<span id="relnotes-1-2-0" />
<span id="id5" />
<span id="id11" />
## 1.2.0
<span id="relnotes-1-2-0-prelude" />
<span id="id6" />
<span id="id12" />
### Prelude
@ -460,7 +536,7 @@ The Qiskit 1.2.0 release focuses mainly on improving performance and quality of
<span id="relnotes-1-2-0-bug-fixes" />
<span id="id7" />
<span id="id13" />
### Bug Fixes

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.8 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.7 KiB

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB