Skip to content

Commit 5f04496

Browse files
Fix typo; update contributing guidelines (amazon-braket#76)
* Fix typo; update contributing guidelines * Update CONTRIBUTING.md * re-run notebook for output Co-authored-by: Cody Wang <speller26@gmail.com>
1 parent ae45631 commit 5f04496

File tree

2 files changed

+31
-33
lines changed

2 files changed

+31
-33
lines changed

CONTRIBUTING.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ When you make a contribution please ensure that you
5454
1. Follow the existing flow of a notebook ([example](https://github.com/aws/amazon-braket-examples/blob/main/examples/getting_started/1_Running_quantum_circuits_on_simulators.ipynb)).
5555
1. Do not duplicate existing information but refer to other examples as relevant.
5656
1. Only have Open Source licensed dependencies in your example.
57-
1. Ensure that your example runs without issues on both a recent Braket Notebook Instance (create a new Braket Notebook Instance or restart one from Amazon Braket [in the console](https://docs.aws.amazon.com/braket/latest/developerguide/braket-get-started-create-notebook.html)) and locally, using our most [recently released Amazon Braket SDK version](https://github.com/aws/amazon-braket-sdk-python/blob/main/README.md#installing-the-amazon-braket-python-sdk).
58-
59-
57+
1. Ensure that your example runs without issues on both a recent Braket Notebook Instance (create a new Braket Notebook Instance or restart one from Amazon Braket [in the console](https://docs.aws.amazon.com/braket/latest/developerguide/braket-get-started-create-notebook.html)) and locally, using our most [recently released Amazon Braket SDK version](https://github.com/aws/amazon-braket-sdk-python/blob/main/README.md#installing-the-amazon-braket-python-sdk). Run the entire notebook by clicking `Cells > Run All`, either in the console or locally, and confirm that every cell completes without error.
6058
### Send a Pull Request
6159

6260
GitHub provides additional documentation on [Creating a Pull Request](https://help.github.com/articles/creating-a-pull-request/).

examples/braket_features/Simulating_Noise_On_Amazon_Braket.ipynb

+30-30
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
},
6565
{
6666
"cell_type": "code",
67-
"execution_count": 1,
67+
"execution_count": 2,
6868
"source": [
6969
"from braket.circuits import Circuit, Observable, Gate, Noise\n",
7070
"from braket.devices import LocalSimulator\n",
@@ -86,7 +86,7 @@
8686
},
8787
{
8888
"cell_type": "code",
89-
"execution_count": 2,
89+
"execution_count": 3,
9090
"source": [
9191
"# enter the S3 bucket you created during onboarding (or any other bucket starting with \"amazon-braket-\") \n",
9292
"my_bucket = \"amazon-braket-Your-Bucket-Name\" # the name of the bucket\n",
@@ -107,7 +107,7 @@
107107
},
108108
{
109109
"cell_type": "code",
110-
"execution_count": 3,
110+
"execution_count": 4,
111111
"source": [
112112
"# build a simple circuit\n",
113113
"circ = Circuit().h(0).cnot(0,1)\n",
@@ -134,7 +134,7 @@
134134
"output_type": "stream",
135135
"name": "stdout",
136136
"text": [
137-
"measurement results: Counter({'00': 418, '11': 385, '01': 102, '10': 95})\n"
137+
"measurement results: Counter({'00': 431, '11': 410, '01': 88, '10': 71})\n"
138138
]
139139
}
140140
],
@@ -151,7 +151,7 @@
151151
},
152152
{
153153
"cell_type": "code",
154-
"execution_count": 4,
154+
"execution_count": 5,
155155
"source": [
156156
"def ghz_circuit(n_qubits: int) -> Circuit:\n",
157157
" \"\"\"\n",
@@ -189,7 +189,7 @@
189189
"output_type": "stream",
190190
"name": "stdout",
191191
"text": [
192-
"measurement results: Counter({'0000000000000': 2, '0011000000001': 1, '0111110000000': 1, '1000010100000': 1, '1000001000000': 1, '1110111111110': 1, '1110000000011': 1, '0011001000000': 1, '0000001101011': 1})\n"
192+
"measurement results: Counter({'1111111111000': 1, '0000000000001': 1, '0000000011111': 1, '1111001000000': 1, '1011111111111': 1, '0000000000000': 1, '1111100000000': 1, '1110000001111': 1, '1111111000111': 1, '0010000000000': 1})\n"
193193
]
194194
}
195195
],
@@ -245,7 +245,7 @@
245245
},
246246
{
247247
"cell_type": "code",
248-
"execution_count": 5,
248+
"execution_count": 6,
249249
"source": [
250250
"# define a bit flip noise channel with probability = 0.1\n",
251251
"noise = Noise.BitFlip(probability=0.1)\n",
@@ -284,7 +284,7 @@
284284
},
285285
{
286286
"cell_type": "code",
287-
"execution_count": 6,
287+
"execution_count": 7,
288288
"source": [
289289
"# define a phase flip noise channel\n",
290290
"noise = Noise.PhaseFlip(probability=0.1)\n",
@@ -317,7 +317,7 @@
317317
},
318318
{
319319
"cell_type": "code",
320-
"execution_count": 7,
320+
"execution_count": 8,
321321
"source": [
322322
"# creat an arbitrary 2-qubit Kraus matrix\n",
323323
"E0 = unitary_group.rvs(4) * np.sqrt(0.2) \n",
@@ -339,7 +339,7 @@
339339
},
340340
{
341341
"cell_type": "code",
342-
"execution_count": 8,
342+
"execution_count": 9,
343343
"source": [
344344
"K_invalid = [np.random.randn(2,2), np.random.randn(2,2)] \n",
345345
"\n",
@@ -377,7 +377,7 @@
377377
},
378378
{
379379
"cell_type": "code",
380-
"execution_count": 9,
380+
"execution_count": 10,
381381
"source": [
382382
"# apply depolarizing noise\n",
383383
"circ = Circuit().x(0).x(1).cnot(0,1).depolarizing(1, probability=0.2).x(0).two_qubit_dephasing(target1=0, target2=1, probability=0.1)\n",
@@ -438,7 +438,7 @@
438438
},
439439
{
440440
"cell_type": "code",
441-
"execution_count": 10,
441+
"execution_count": 11,
442442
"source": [
443443
"noise = Noise.PhaseDamping(gamma=0.1)\n",
444444
"\n",
@@ -491,7 +491,7 @@
491491
},
492492
{
493493
"cell_type": "code",
494-
"execution_count": 11,
494+
"execution_count": 12,
495495
"source": [
496496
"# the noise channel is applied to all the X gates in the circuit\n",
497497
"circ = Circuit().x(0).y(1).cnot(0,2).x(1).z(2)\n",
@@ -529,7 +529,7 @@
529529
},
530530
{
531531
"cell_type": "code",
532-
"execution_count": 12,
532+
"execution_count": 13,
533533
"source": [
534534
"U1=unitary_group.rvs(4)\n",
535535
"U2=unitary_group.rvs(4)\n",
@@ -568,7 +568,7 @@
568568
},
569569
{
570570
"cell_type": "code",
571-
"execution_count": 13,
571+
"execution_count": 14,
572572
"source": [
573573
"# the noise channel is applied to every gate on qubits 0 and 2\n",
574574
"circ = Circuit().x(0).y(1).cnot(0,2).x(1).z(2)\n",
@@ -606,7 +606,7 @@
606606
},
607607
{
608608
"cell_type": "code",
609-
"execution_count": 14,
609+
"execution_count": 15,
610610
"source": [
611611
"# the noise channel is applied to X gate on qubits 0\n",
612612
"circ = Circuit().x(0).y(1).cnot(0,2).x(0).x(1).z(2)\n",
@@ -644,7 +644,7 @@
644644
},
645645
{
646646
"cell_type": "code",
647-
"execution_count": 15,
647+
"execution_count": 16,
648648
"source": [
649649
"# define two noise channels\n",
650650
"noise1 = Noise.Depolarizing(probability=0.1)\n",
@@ -686,7 +686,7 @@
686686
},
687687
{
688688
"cell_type": "code",
689-
"execution_count": 16,
689+
"execution_count": 17,
690690
"source": [
691691
"# define a two-qubit noise channel\n",
692692
"noise = Noise.TwoQubitDephasing(probability=0.1)\n",
@@ -743,7 +743,7 @@
743743
},
744744
{
745745
"cell_type": "code",
746-
"execution_count": 17,
746+
"execution_count": 18,
747747
"source": [
748748
"# define a noise channel\n",
749749
"noise = Noise.Depolarizing(probability=0.1)\n",
@@ -784,7 +784,7 @@
784784
},
785785
{
786786
"cell_type": "code",
787-
"execution_count": 18,
787+
"execution_count": 19,
788788
"source": [
789789
"# define a two-qubit noise channel\n",
790790
"noise = Noise.TwoQubitDephasing(probability=0.1)\n",
@@ -839,7 +839,7 @@
839839
},
840840
{
841841
"cell_type": "code",
842-
"execution_count": 19,
842+
"execution_count": 20,
843843
"source": [
844844
"# define a noise channel\n",
845845
"noise = Noise.Depolarizing(probability=0.1)\n",
@@ -888,7 +888,7 @@
888888
},
889889
{
890890
"cell_type": "code",
891-
"execution_count": 20,
891+
"execution_count": 21,
892892
"source": [
893893
"# define a noise channel\n",
894894
"noise = Noise.PhaseFlip(probability=0.2)\n",
@@ -935,7 +935,7 @@
935935
},
936936
{
937937
"cell_type": "code",
938-
"execution_count": 21,
938+
"execution_count": 22,
939939
"source": [
940940
"# define the noise channel\n",
941941
"noise = Noise.AmplitudeDamping(gamma=0.1)\n",
@@ -951,7 +951,7 @@
951951
"circ.density_matrix(target=[0,1])\n",
952952
"print(circ)\n",
953953
"\n",
954-
"# choose the noise simualtor, which is called \"braket_dm\"\n",
954+
"# choose the noise simulator, which is called \"braket_dm\"\n",
955955
"device = LocalSimulator(\"braket_dm\")\n",
956956
"# run the circuit\n",
957957
"task = device.run(circ, shots=0)\n",
@@ -1004,7 +1004,7 @@
10041004
},
10051005
{
10061006
"cell_type": "code",
1007-
"execution_count": 22,
1007+
"execution_count": 23,
10081008
"source": [
10091009
"# create a circuit\n",
10101010
"circ = Circuit().x(0).y(1).cnot(0,2).x(1).z(2)\n",
@@ -1038,9 +1038,9 @@
10381038
"\n",
10391039
"T : | 0 | 1 | 2 | Result Types |\n",
10401040
"- Probability is: \n",
1041-
"[0.08 0.05 0. 0. 0.2 0.67 0. 0. ]\n",
1041+
"[0.11 0.08 0. 0. 0.12 0.69 0. 0. ]\n",
10421042
"- Expectation value <Z_0> is: \n",
1043-
"-0.74\n"
1043+
"-0.62\n"
10441044
]
10451045
}
10461046
],
@@ -1058,7 +1058,7 @@
10581058
"metadata": {
10591059
"kernelspec": {
10601060
"name": "python3",
1061-
"display_name": "Python 3.7.6 64-bit ('base': conda)"
1061+
"display_name": "Python 3.7.10 64-bit ('Braket': conda)"
10621062
},
10631063
"language_info": {
10641064
"codemirror_mode": {
@@ -1070,10 +1070,10 @@
10701070
"name": "python",
10711071
"nbconvert_exporter": "python",
10721072
"pygments_lexer": "ipython3",
1073-
"version": "3.7.6"
1073+
"version": "3.7.10"
10741074
},
10751075
"interpreter": {
1076-
"hash": "0253d37730c9ef949b31486b4cff0d658c43b30ac02c14841de7d7631b67ad05"
1076+
"hash": "16295940b2ad1780f80ab35486298f56b74905bdf7e3032c7f9c97990fe8396d"
10771077
}
10781078
},
10791079
"nbformat": 4,

0 commit comments

Comments
 (0)