Coverage for src/braket/ir/jaqcd/program_v1.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 Field
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)
60from braket.schema_common import BraketSchemaBase, BraketSchemaHeader
62GateInstructions = Union[
63 CCNot,
64 CNot,
65 CPhaseShift,
66 CPhaseShift00,
67 CPhaseShift01,
68 CPhaseShift10,
69 CSwap,
70 CY,
71 CZ,
72 H,
73 I,
74 ISwap,
75 PhaseShift,
76 PSwap,
77 Rx,
78 Ry,
79 Rz,
80 S,
81 Swap,
82 Si,
83 T,
84 Ti,
85 Unitary,
86 V,
87 Vi,
88 X,
89 XX,
90 XY,
91 Y,
92 YY,
93 Z,
94 ZZ,
95]
97Results = Union[Amplitude, Expectation, Probability, Sample, StateVector, Variance]
100class Program(BraketSchemaBase):
101 """
102 Root object of the JsonAwsQuantumCircuitDescription IR.
106 Attributes:
107 braketSchemaHeader (BraketSchemaHeader): Schema header. Users do not need
108 to set this value. Only default is allowed.
109 instructions (List[GateInstructions]): List of instructions.
110 basis_rotation_instructions (List[GateInstructions]): List of instructions for
111 rotation to desired measurement bases. Default is None.
112 results (List[Union[Amplitude, Expectation, Probability, Sample, StateVector, Variance]]):
113 List of requested results. Default is None.
115 Examples:
116 >>> Program(instructions=[H(target=0), Rz(angle=0.15, target=1)])
117 >>> Program(instructions=[H(target=0), CNot(control=0, target=1)],
118 ... results=[Expectation(targets=[0], observable=['x'])],
119 ... basis_rotation_instructions=[H(target=0)])
122 Note:
123 The type `GateInstructions` includes the following instructions:
124 CCNot,
125 CNot,
126 CPhaseShift,
127 CPhaseShift00,
128 CPhaseShift01,
129 CPhaseShift10,
130 CSwap,
131 CY,
132 CZ,
133 H,
134 I,
135 ISwap,
136 PhaseShift,
137 PSwap,
138 Rx,
139 Ry,
140 Rz,
141 S,
142 Swap,
143 Si,
144 T,
145 Ti,
146 Unitary,
147 V,
148 Vi,
149 X,
150 XX,
151 XY,
152 Y,
153 YY,
154 Z,
155 ZZ
156 """
158 _PROGRAM_HEADER = BraketSchemaHeader(name="braket.ir.jaqcd.program", version="1")
159 braketSchemaHeader: BraketSchemaHeader = Field(default=_PROGRAM_HEADER, const=_PROGRAM_HEADER)
160 instructions: List[GateInstructions]
161 results: Optional[List[Results]]
162 basis_rotation_instructions: Optional[List[GateInstructions]]