Skip to content

Commit ac2ea5a

Browse files
authoredMar 24, 2025··
style: update linter to use UP and SIM rules (#695)
1 parent 5d15aac commit ac2ea5a

File tree

117 files changed

+1364
-1386
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+1364
-1386
lines changed
 

‎examples/advanced_circuits_algorithms/Grover/Grover.ipynb

+12-26
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,7 @@
221221
"# Helper function to build C-C-Z gate\n",
222222
"@circuit.subroutine(register=True)\n",
223223
"def ccz(targets=[0, 1, 2]):\n",
224-
" \"\"\"\n",
225-
" implementation of three-qubit gate CCZ\n",
226-
" \"\"\"\n",
224+
" \"\"\"Implementation of three-qubit gate CCZ\"\"\"\n",
227225
" # define three-qubit CCZ gate\n",
228226
" ccz_gate = np.array(\n",
229227
" [\n",
@@ -264,9 +262,7 @@
264262
"\n",
265263
"# helper function for initialization\n",
266264
"def initialize(n_qubits=3):\n",
267-
" \"\"\"\n",
268-
" function to apply hadamard to all qubits\n",
269-
" \"\"\"\n",
265+
" \"\"\"Function to apply hadamard to all qubits\"\"\"\n",
270266
" # Initialize with superposition\n",
271267
" circ = Circuit()\n",
272268
" circ.h(np.arange(n_qubits))\n",
@@ -276,9 +272,7 @@
276272
"\n",
277273
"# helper function for phase oracle\n",
278274
"def oracle(item):\n",
279-
" \"\"\"\n",
280-
" function to apply oracle for given target item\n",
281-
" \"\"\"\n",
275+
" \"\"\"Function to apply oracle for given target item\"\"\"\n",
282276
" # instantiate circuit object\n",
283277
" circ = Circuit()\n",
284278
"\n",
@@ -290,9 +284,7 @@
290284
"\n",
291285
"# helper function for amplification\n",
292286
"def amplify(n_qubits=3):\n",
293-
" \"\"\"\n",
294-
" function for amplitude amplification\n",
295-
" \"\"\"\n",
287+
" \"\"\"Function for amplitude amplification\"\"\"\n",
296288
" # instantiate circuit object\n",
297289
" circ = Circuit()\n",
298290
"\n",
@@ -306,9 +298,7 @@
306298
"\n",
307299
"# helper function for grover algorithm\n",
308300
"def grover(item, n_qubits=3, n_reps=1):\n",
309-
" \"\"\"\n",
310-
" function to put together individual modules of Grover algorithm\n",
311-
" \"\"\"\n",
301+
" \"\"\"Function to put together individual modules of Grover algorithm\"\"\"\n",
312302
" # initialize\n",
313303
" grover_circ = initialize()\n",
314304
" # oracle and amplify\n",
@@ -444,7 +434,7 @@
444434
" \"supportedOperations\"\n",
445435
"]\n",
446436
"# Note: This field also exists for other devices like the QPUs\n",
447-
"print(\"Quantum Gates supported by {}:\\n {}\".format(device_name, device_operations))"
437+
"print(f\"Quantum Gates supported by {device_name}:\\n {device_operations}\")"
448438
]
449439
},
450440
{
@@ -695,7 +685,7 @@
695685
" \"supportedOperations\"\n",
696686
"]\n",
697687
"# Note: This field also exists for other devices like the QPUs\n",
698-
"print(\"Quantum Gates supported by {}:\\n {}\".format(device_name, device_operations))"
688+
"print(f\"Quantum Gates supported by {device_name}:\\n {device_operations}\")"
699689
]
700690
},
701691
{
@@ -718,9 +708,7 @@
718708
"source": [
719709
"@circuit.subroutine(register=True)\n",
720710
"def CCNot(controls=[0, 1], target=2):\n",
721-
" \"\"\"\n",
722-
" build CCNOT from H, CNOT, T, Ti\n",
723-
" \"\"\"\n",
711+
" \"\"\"Build CCNOT from H, CNOT, T, Ti\"\"\"\n",
724712
" cQb1, cQb2 = controls\n",
725713
" circ = (\n",
726714
" Circuit()\n",
@@ -745,9 +733,7 @@
745733
"\n",
746734
"\n",
747735
"def CCZ(controls=[0, 1], target=2):\n",
748-
" \"\"\"\n",
749-
" build CCZ from H and CCNOT\n",
750-
" \"\"\"\n",
736+
" \"\"\"Build CCZ from H and CCNOT\"\"\"\n",
751737
" circ = Circuit().h(target).CCNot(controls, target).h(target)\n",
752738
" return circ\n",
753739
"\n",
@@ -1024,7 +1010,7 @@
10241010
" shots = metadata[\"shots\"]\n",
10251011
" machine = metadata[\"deviceArn\"]\n",
10261012
" # print example metadata\n",
1027-
" print(\"{} shots taken on machine {}.\".format(shots, machine))\n",
1013+
" print(f\"{shots} shots taken on machine {machine}.\")\n",
10281014
"\n",
10291015
" # get measurement counts\n",
10301016
" counts = results.measurement_counts\n",
@@ -1091,10 +1077,10 @@
10911077
"print(\"Quantum Task Summary\")\n",
10921078
"print(t.quantum_tasks_statistics())\n",
10931079
"print(\n",
1094-
" \"Note: Charges shown are estimates based on your Amazon Braket simulator and quantum processing unit (QPU) task usage. Estimated charges shown may differ from your actual charges. Estimated charges do not factor in any discounts or credits, and you may experience additional charges based on your use of other services such as Amazon Elastic Compute Cloud (Amazon EC2).\"\n",
1080+
" \"Note: Charges shown are estimates based on your Amazon Braket simulator and quantum processing unit (QPU) task usage. Estimated charges shown may differ from your actual charges. Estimated charges do not factor in any discounts or credits, and you may experience additional charges based on your use of other services such as Amazon Elastic Compute Cloud (Amazon EC2).\",\n",
10951081
")\n",
10961082
"print(\n",
1097-
" f\"Estimated cost to run this example: {t.qpu_tasks_cost() + t.simulator_tasks_cost():.2f} USD\"\n",
1083+
" f\"Estimated cost to run this example: {t.qpu_tasks_cost() + t.simulator_tasks_cost():.2f} USD\",\n",
10981084
")"
10991085
]
11001086
},

‎examples/advanced_circuits_algorithms/Quantum_Amplitude_Amplification/Quantum_Amplitude_Amplification.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,7 @@
925925
"\n",
926926
"# Print the final amplitude of |11>:\n",
927927
"info = \"Maximum amplified amplitude <110|Final State> after approximately\"\n",
928-
"print(info + \" {} Grover iterations:\\n {}\".format(max_iter, result.values[0]))"
928+
"print(info + f\" {max_iter} Grover iterations:\\n {result.values[0]}\")"
929929
]
930930
},
931931
{

0 commit comments

Comments
 (0)
Please sign in to comment.