Coverage for src/braket/ir/jaqcd/program.py : 100%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# Copyright 2019-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"). You
4# may not use this file except in compliance with the License. A copy of
5# the License is located at
6#
7# http://aws.amazon.com/apache2.0/
8#
9# or in the "license" file accompanying this file. This file is
10# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11# ANY KIND, either express or implied. See the License for the specific
12# language governing permissions and limitations under the License.
14from typing import List, Optional, Union
16from braket.ir.jaqcd.instructions import (
17 CY,
18 CZ,
19 XX,
20 XY,
21 YY,
22 ZZ,
23 CCNot,
24 CNot,
25 CPhaseShift,
26 CPhaseShift00,
27 CPhaseShift01,
28 CPhaseShift10,
29 CSwap,
30 H,
31 I,
32 ISwap,
33 PhaseShift,
34 PSwap,
35 Rx,
36 Ry,
37 Rz,
38 S,
39 Si,
40 Swap,
41 T,
42 Ti,
43 Unitary,
44 V,
45 Vi,
46 X,
47 Y,
48 Z,
49)
50from braket.ir.jaqcd.results import (
51 Amplitude,
52 Expectation,
53 Probability,
54 Sample,
55 StateVector,
56 Variance,
57)
58from pydantic import BaseModel
60GateInstructions = Union[
61 CCNot,
62 CNot,
63 CPhaseShift,
64 CPhaseShift00,
65 CPhaseShift01,
66 CPhaseShift10,
67 CSwap,
68 CY,
69 CZ,
70 H,
71 I,
72 ISwap,
73 PhaseShift,
74 PSwap,
75 Rx,
76 Ry,
77 Rz,
78 S,
79 Swap,
80 Si,
81 T,
82 Ti,
83 Unitary,
84 V,
85 Vi,
86 X,
87 XX,
88 XY,
89 Y,
90 YY,
91 Z,
92 ZZ,
93]
96class Program(BaseModel):
97 """
98 Root object of the JsonAwsQuantumCircuitDescription IR.
102 Attributes:
103 - instructions: List of instructions.
104 - basis_rotation_instructions: List of instructions for rotation to desired measurement
105 bases
106 - results: List of requested results
108 Examples:
109 >>> Program(instructions=[H(target=0), Rz(angle=0.15, target=1)])
110 >>> Program(instructions=[H(target=0), CNot(control=0, target=1)],
111 ... results=[Expectation(targets=[0], observable=['x'])],
112 ... basis_rotation_instructions=[H(target=0)])
115 Note:
116 The type `GateInstructions` includes the following instructions:
117 CCNot,
118 CNot,
119 CPhaseShift,
120 CPhaseShift00,
121 CPhaseShift01,
122 CPhaseShift10,
123 CSwap,
124 CY,
125 CZ,
126 H,
127 I,
128 ISwap,
129 PhaseShift,
130 PSwap,
131 Rx,
132 Ry,
133 Rz,
134 S,
135 Swap,
136 Si,
137 T,
138 Ti,
139 Unitary,
140 V,
141 Vi,
142 X,
143 XX,
144 XY,
145 Y,
146 YY,
147 Z,
148 ZZ
149 """
151 instructions: List[GateInstructions]
152 results: Optional[
153 List[Union[Amplitude, Expectation, Probability, Sample, StateVector, Variance]]
154 ]
155 basis_rotation_instructions: Optional[List[GateInstructions]]