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 pydantic import BaseModel
18from braket.ir.jaqcd.instructions import (
19 CY,
20 CZ,
21 XX,
22 XY,
23 YY,
24 ZZ,
25 CCNot,
26 CNot,
27 CPhaseShift,
28 CPhaseShift00,
29 CPhaseShift01,
30 CPhaseShift10,
31 CSwap,
32 H,
33 I,
34 ISwap,
35 PhaseShift,
36 PSwap,
37 Rx,
38 Ry,
39 Rz,
40 S,
41 Si,
42 Swap,
43 T,
44 Ti,
45 Unitary,
46 V,
47 Vi,
48 X,
49 Y,
50 Z,
51)
52from braket.ir.jaqcd.results import (
53 Amplitude,
54 Expectation,
55 Probability,
56 Sample,
57 StateVector,
58 Variance,
59)
61GateInstructions = Union[
62 CCNot,
63 CNot,
64 CPhaseShift,
65 CPhaseShift00,
66 CPhaseShift01,
67 CPhaseShift10,
68 CSwap,
69 CY,
70 CZ,
71 H,
72 I,
73 ISwap,
74 PhaseShift,
75 PSwap,
76 Rx,
77 Ry,
78 Rz,
79 S,
80 Swap,
81 Si,
82 T,
83 Ti,
84 Unitary,
85 V,
86 Vi,
87 X,
88 XX,
89 XY,
90 Y,
91 YY,
92 Z,
93 ZZ,
94]
97class Program(BaseModel):
98 """
99 Root object of the JsonAwsQuantumCircuitDescription IR.
103 Attributes:
104 - instructions: List of instructions.
105 - basis_rotation_instructions: List of instructions for rotation to desired measurement
106 bases
107 - results: List of requested results
109 Examples:
110 >>> Program(instructions=[H(target=0), Rz(angle=0.15, target=1)])
111 >>> Program(instructions=[H(target=0), CNot(control=0, target=1)],
112 ... results=[Expectation(targets=[0], observable=['x'])],
113 ... basis_rotation_instructions=[H(target=0)])
116 Note:
117 The type `GateInstructions` includes the following instructions:
118 CCNot,
119 CNot,
120 CPhaseShift,
121 CPhaseShift00,
122 CPhaseShift01,
123 CPhaseShift10,
124 CSwap,
125 CY,
126 CZ,
127 H,
128 I,
129 ISwap,
130 PhaseShift,
131 PSwap,
132 Rx,
133 Ry,
134 Rz,
135 S,
136 Swap,
137 Si,
138 T,
139 Ti,
140 Unitary,
141 V,
142 Vi,
143 X,
144 XX,
145 XY,
146 Y,
147 YY,
148 Z,
149 ZZ
150 """
152 instructions: List[GateInstructions]
153 results: Optional[
154 List[Union[Amplitude, Expectation, Probability, Sample, StateVector, Variance]]
155 ]
156 basis_rotation_instructions: Optional[List[GateInstructions]]