Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 48 additions & 8 deletions docs/guides/construct-circuits.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,21 @@
]
},
"source": [
"{/*\n",
" DO NOT EDIT THIS CELL!!!\n",
" This cell's content is generated automatically by a script. Anything you add\n",
" here will be removed next time the notebook is run. To add new content, create\n",
" a new cell before or after this one.\n",
"*/}\n",
"\n",
"<details>\n",
"<summary><b>Package versions</b></summary>\n",
"\n",
"The code on this page was developed using the following requirements.\n",
"We recommend using these versions or newer.\n",
"\n",
"```\n",
"qiskit[all]~=2.1.1\n",
"qiskit[all]~=2.3.0\n",
"```\n",
"</details>"
]
Expand Down Expand Up @@ -88,9 +95,9 @@
{
"data": {
"text/plain": [
"[Qubit(QuantumRegister(2, 'qreg1'), 0),\n",
" Qubit(QuantumRegister(2, 'qreg1'), 1),\n",
" Qubit(QuantumRegister(1, 'qreg2'), 0)]"
"[<Qubit register=(2, \"qreg1\"), index=0>,\n",
" <Qubit register=(2, \"qreg1\"), index=1>,\n",
" <Qubit register=(1, \"qreg2\"), index=0>]"
]
},
"execution_count": 2,
Expand Down Expand Up @@ -434,7 +441,7 @@
"id": "87f1e053",
"metadata": {},
"source": [
"<span id=\"measure-qubits\"></span>\n",
"<span id=\"measure-qubits\"></span>\n",
"## Measure qubits\n",
"\n",
"Measurements are used to sample the states of individual qubits and transfer the results to a classical register. Note that if you are submitting circuits to a [Sampler](./primitives#sampler) primitive, measurements are required. However, circuits submitted to an [Estimator](./primitives#estimator) primitive must not contain measurements.\n",
Expand All @@ -458,7 +465,7 @@
{
"data": {
"text/plain": [
"<Image src=\"/docs/images/guides/construct-circuits/extracted-outputs/0cdb2273-0.avif\" alt=\"Output of the previous code cell\" />"
"<Image src=\"/docs/images/guides/construct-circuits/extracted-outputs/0cdb2273-0.svg\" alt=\"Output of the previous code cell\" />"
]
},
"execution_count": 12,
Expand All @@ -481,7 +488,7 @@
{
"data": {
"text/plain": [
"<Image src=\"/docs/images/guides/construct-circuits/extracted-outputs/6f33698c-0.avif\" alt=\"Output of the previous code cell\" />"
"<Image src=\"/docs/images/guides/construct-circuits/extracted-outputs/6f33698c-0.svg\" alt=\"Output of the previous code cell\" />"
]
},
"execution_count": 13,
Expand All @@ -504,7 +511,7 @@
{
"data": {
"text/plain": [
"<Image src=\"/docs/images/guides/construct-circuits/extracted-outputs/ca3f225f-0.avif\" alt=\"Output of the previous code cell\" />"
"<Image src=\"/docs/images/guides/construct-circuits/extracted-outputs/ca3f225f-0.svg\" alt=\"Output of the previous code cell\" />"
]
},
"execution_count": 14,
Expand Down Expand Up @@ -624,6 +631,39 @@
"qc.parameters"
]
},
{
"cell_type": "markdown",
"id": "8e415c37",
"metadata": {},
"source": [
"### Change a parameter's name\n",
"\n",
"By default, parameter names for a parameterized circuit are prefixed by `x`- for example, `x[0]`. You can change the names after they are defined, as shown in the following example."
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "1d3e6424",
"metadata": {},
"outputs": [],
"source": [
"from qiskit.circuit.library import z_feature_map\n",
"from qiskit.circuit import ParameterVector\n",
"\n",
"# Define a parameterized circuit with default names\n",
"# For example, x[0]\n",
"circuit = z_feature_map(2)\n",
"\n",
"# Set new parameter names\n",
"# They will now be prefixed by `hi` instead\n",
"# For example, hi[0]\n",
"training_params = ParameterVector(\"hi\", 2)\n",
"\n",
"# Assign parameter names to the quantum circuit\n",
"circuit = circuit.assign_parameters(parameters=training_params)"
]
},
{
"cell_type": "markdown",
"id": "ae19e48d",
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading