15
15
import pytest
16
16
17
17
import cirq
18
- from cirq .transformers import gauge_compiling as gc
18
+ from cirq .transformers import gauge_compiling
19
19
20
20
21
21
def test_add_gauge_merges_gates ():
22
- tr = gc .IdleMomentsGauge (2 , gauges = 'pauli' )
22
+ tr = gauge_compiling .IdleMomentsGauge (2 , gauges = 'pauli' )
23
23
24
24
circuit = cirq .Circuit .from_moments ([], [], [], cirq .X (cirq .q (0 )), [], [], cirq .X (cirq .q (0 )))
25
25
transformed_circuit = tr (circuit , rng_or_seed = 0 )
@@ -36,7 +36,7 @@ def test_add_gauge_merges_gates():
36
36
37
37
38
38
def test_add_gauge_respects_ignore_tag ():
39
- tr = gc .IdleMomentsGauge (2 , gauges = 'pauli' )
39
+ tr = gauge_compiling .IdleMomentsGauge (2 , gauges = 'pauli' )
40
40
41
41
circuit = cirq .Circuit .from_moments (
42
42
cirq .X (cirq .q (0 )), [], [], cirq .X (cirq .q (0 )).with_tags ('ignore' )
@@ -53,7 +53,7 @@ def test_add_gauge_respects_ignore_tag():
53
53
54
54
55
55
def test_add_gauge_respects_ignore_moment ():
56
- tr = gc .IdleMomentsGauge (2 , gauges = 'pauli' )
56
+ tr = gauge_compiling .IdleMomentsGauge (2 , gauges = 'pauli' )
57
57
58
58
circuit = cirq .Circuit .from_moments (
59
59
cirq .X (cirq .q (0 )), [], [], cirq .Moment (cirq .X (cirq .q (0 ))).with_tags ('ignore' )
@@ -70,7 +70,7 @@ def test_add_gauge_respects_ignore_moment():
70
70
71
71
72
72
def test_add_gauge_on_prefix ():
73
- tr = gc .IdleMomentsGauge (3 , gauges = 'clifford' , gauge_beginning = True )
73
+ tr = gauge_compiling .IdleMomentsGauge (3 , gauges = 'clifford' , gauge_beginning = True )
74
74
75
75
circuit = cirq .Circuit .from_moments ([], [], [], cirq .CNOT (cirq .q (0 ), cirq .q (1 )))
76
76
transformed_circuit = tr (circuit , rng_or_seed = 0 )
@@ -89,7 +89,7 @@ def test_add_gauge_on_prefix():
89
89
90
90
91
91
def test_add_gauge_on_prefix_with_merge ():
92
- tr = gc .IdleMomentsGauge (3 , gauges = [cirq .Y ], gauge_beginning = True )
92
+ tr = gauge_compiling .IdleMomentsGauge (3 , gauges = [cirq .Y ], gauge_beginning = True )
93
93
94
94
circuit = cirq .Circuit .from_moments ([], [], [], cirq .X (cirq .q (0 )))
95
95
transformed_circuit = tr (circuit , rng_or_seed = 0 )
@@ -102,7 +102,7 @@ def test_add_gauge_on_prefix_with_merge():
102
102
103
103
104
104
def test_add_gauge_on_suffix ():
105
- tr = gc .IdleMomentsGauge (3 , gauges = 'inv_clifford' , gauge_ending = True )
105
+ tr = gauge_compiling .IdleMomentsGauge (3 , gauges = 'inv_clifford' , gauge_ending = True )
106
106
107
107
circuit = cirq .Circuit .from_moments (cirq .CNOT (cirq .q (0 ), cirq .q (1 )), [], [], [])
108
108
transformed_circuit = tr (circuit , rng_or_seed = 0 )
@@ -121,7 +121,7 @@ def test_add_gauge_on_suffix():
121
121
122
122
123
123
def test_add_gauge_on_suffix_with_merge ():
124
- tr = gc .IdleMomentsGauge (3 , gauges = [cirq .Y ], gauge_ending = True )
124
+ tr = gauge_compiling .IdleMomentsGauge (3 , gauges = [cirq .Y ], gauge_ending = True )
125
125
126
126
circuit = cirq .Circuit .from_moments (cirq .X (cirq .q (0 )), [], [], [])
127
127
transformed_circuit = tr (circuit , rng_or_seed = 0 )
@@ -134,15 +134,15 @@ def test_add_gauge_on_suffix_with_merge():
134
134
135
135
136
136
def test_add_gauge_respects_min_length ():
137
- tr = gc .IdleMomentsGauge (2 , gauges = [cirq .X ])
137
+ tr = gauge_compiling .IdleMomentsGauge (2 , gauges = [cirq .X ])
138
138
139
139
circuit = cirq .Circuit .from_moments (cirq .X (cirq .q (0 )), [], cirq .X (cirq .q (0 )))
140
140
transformed_circuit = tr (circuit , rng_or_seed = 0 )
141
141
assert transformed_circuit == circuit
142
142
143
143
144
144
def test_context_with_deep_raises ():
145
- tr = gc .IdleMomentsGauge (2 , gauges = [cirq .X ])
145
+ tr = gauge_compiling .IdleMomentsGauge (2 , gauges = [cirq .X ])
146
146
147
147
circuit = cirq .Circuit .from_moments (cirq .X (cirq .q (0 )), [], cirq .X (cirq .q (0 )))
148
148
with pytest .raises (
@@ -153,23 +153,23 @@ def test_context_with_deep_raises():
153
153
154
154
def test_gauge_with_invalid_name_raises ():
155
155
with pytest .raises (ValueError , match = 'valid gauge' ):
156
- _ = gc .IdleMomentsGauge (2 , gauges = 'invalid' )
156
+ _ = gauge_compiling .IdleMomentsGauge (2 , gauges = 'invalid' )
157
157
158
158
159
159
def test_repr ():
160
- assert repr (gc .IdleMomentsGauge (3 , gauges = 'pauli' )) == (
160
+ assert repr (gauge_compiling .IdleMomentsGauge (3 , gauges = 'pauli' )) == (
161
161
'IdleMomentsGauge(min_length=3, gauges="pauli", '
162
162
'gauge_beginning=False, gauge_ending=False)'
163
163
)
164
- assert repr (gc .IdleMomentsGauge (4 , gauges = 'clifford' )) == (
164
+ assert repr (gauge_compiling .IdleMomentsGauge (4 , gauges = 'clifford' )) == (
165
165
'IdleMomentsGauge(min_length=4, gauges="clifford", '
166
166
'gauge_beginning=False, gauge_ending=False)'
167
167
)
168
- assert repr (gc .IdleMomentsGauge (5 , gauges = 'inv_clifford' )) == (
168
+ assert repr (gauge_compiling .IdleMomentsGauge (5 , gauges = 'inv_clifford' )) == (
169
169
'IdleMomentsGauge(min_length=5, gauges="inv_clifford", '
170
170
'gauge_beginning=False, gauge_ending=False)'
171
171
)
172
- assert repr (gc .IdleMomentsGauge (6 , gauges = [cirq .X ])) == (
172
+ assert repr (gauge_compiling .IdleMomentsGauge (6 , gauges = [cirq .X ])) == (
173
173
'IdleMomentsGauge(min_length=6, gauges=(cirq.X,), '
174
174
'gauge_beginning=False, gauge_ending=False)'
175
175
)
0 commit comments