@@ -53,15 +53,15 @@ def noisy_moment(self, moment, system_qubits):
53
53
repetitions = 10 ,
54
54
max_delay = cirq .Duration (nanos = 500 ),
55
55
)
56
- results .plot ()
56
+ results .plot (include_fit = True )
57
57
58
58
59
59
def test_result_eq ():
60
60
eq = cirq .testing .EqualsTester ()
61
61
eq .make_equality_group (
62
62
lambda : cirq .experiments .T1DecayResult (
63
63
data = pd .DataFrame (
64
- columns = ['delay_ns' , 'false_count' , 'true_count' ], index = [0 ], data = [[100.0 , 2 , 8 ]]
64
+ columns = ['delay_ns' , 'false_count' , 'true_count' ], index = [0 ], data = [[100 , 2 , 8 ]]
65
65
)
66
66
)
67
67
)
@@ -103,7 +103,7 @@ def noisy_moment(self, moment, system_qubits):
103
103
data = pd .DataFrame (
104
104
columns = ['delay_ns' , 'false_count' , 'true_count' ],
105
105
index = range (4 ),
106
- data = [[100.0 , 0 , 10 ], [400 .0 , 0 , 10 ], [700 .0 , 10 , 0 ], [1000.0 , 10 , 0 ]],
106
+ data = [[100.0 , 0 , 10 ], [215 .0 , 0 , 10 ], [464 .0 , 0 , 10 ], [1000.0 , 10 , 0 ]],
107
107
)
108
108
)
109
109
@@ -117,13 +117,14 @@ def test_all_on_results():
117
117
min_delay = cirq .Duration (nanos = 100 ),
118
118
max_delay = cirq .Duration (micros = 1 ),
119
119
)
120
- assert results = = cirq .experiments .T1DecayResult (
120
+ desired = cirq .experiments .T1DecayResult (
121
121
data = pd .DataFrame (
122
122
columns = ['delay_ns' , 'false_count' , 'true_count' ],
123
123
index = range (4 ),
124
- data = [[100.0 , 0 , 10 ], [400 .0 , 0 , 10 ], [700 .0 , 0 , 10 ], [1000.0 , 0 , 10 ]],
124
+ data = [[100.0 , 0 , 10 ], [215 .0 , 0 , 10 ], [464 .0 , 0 , 10 ], [1000.0 , 0 , 10 ]],
125
125
)
126
126
)
127
+ assert results == desired , f'{ results .data = } { desired .data = } '
127
128
128
129
129
130
def test_all_off_results ():
@@ -135,13 +136,14 @@ def test_all_off_results():
135
136
min_delay = cirq .Duration (nanos = 100 ),
136
137
max_delay = cirq .Duration (micros = 1 ),
137
138
)
138
- assert results = = cirq .experiments .T1DecayResult (
139
+ desired = cirq .experiments .T1DecayResult (
139
140
data = pd .DataFrame (
140
141
columns = ['delay_ns' , 'false_count' , 'true_count' ],
141
142
index = range (4 ),
142
- data = [[100.0 , 10 , 0 ], [400 .0 , 10 , 0 ], [700 .0 , 10 , 0 ], [1000.0 , 10 , 0 ]],
143
+ data = [[100.0 , 10 , 0 ], [215 .0 , 10 , 0 ], [464 .0 , 10 , 0 ], [1000.0 , 10 , 0 ]],
143
144
)
144
145
)
146
+ assert results == desired , f'{ results .data = } { desired .data = } '
145
147
146
148
147
149
@pytest .mark .usefixtures ('closefigures' )
@@ -150,28 +152,14 @@ def test_curve_fit_plot_works():
150
152
data = pd .DataFrame (
151
153
columns = ['delay_ns' , 'false_count' , 'true_count' ],
152
154
index = range (4 ),
153
- data = [[100.0 , 6 , 4 ], [400 .0 , 10 , 0 ], [700 .0 , 10 , 0 ], [1000.0 , 10 , 0 ]],
155
+ data = [[100.0 , 6 , 4 ], [215 .0 , 10 , 0 ], [464 .0 , 10 , 0 ], [1000.0 , 10 , 0 ]],
154
156
)
155
157
)
156
158
157
159
good_fit .plot (include_fit = True )
158
160
159
161
160
- @pytest .mark .usefixtures ('closefigures' )
161
- def test_curve_fit_plot_warning ():
162
- bad_fit = cirq .experiments .T1DecayResult (
163
- data = pd .DataFrame (
164
- columns = ['delay_ns' , 'false_count' , 'true_count' ],
165
- index = range (4 ),
166
- data = [[100.0 , 10 , 0 ], [400.0 , 10 , 0 ], [700.0 , 10 , 0 ], [1000.0 , 10 , 0 ]],
167
- )
168
- )
169
-
170
- with pytest .warns (RuntimeWarning , match = 'Optimal parameters could not be found for curve fit' ):
171
- bad_fit .plot (include_fit = True )
172
-
173
-
174
- @pytest .mark .parametrize ('t1' , [200 , 500 , 700 ])
162
+ @pytest .mark .parametrize ('t1' , [200.0 , 500.0 , 700.0 ])
175
163
def test_noise_model_continous (t1 ):
176
164
class GradualDecay (cirq .NoiseModel ):
177
165
def __init__ (self , t1 : float ):
@@ -196,10 +184,10 @@ def noisy_moment(self, moment, system_qubits):
196
184
results = cirq .experiments .t1_decay (
197
185
sampler = cirq .DensityMatrixSimulator (noise = GradualDecay (t1 )),
198
186
qubit = cirq .GridQubit (0 , 0 ),
199
- num_points = 4 ,
187
+ num_points = 10 ,
200
188
repetitions = 10 ,
201
- min_delay = cirq .Duration (nanos = 100 ),
202
- max_delay = cirq .Duration (micros = 1 ),
189
+ min_delay = cirq .Duration (nanos = 1 ),
190
+ max_delay = cirq .Duration (micros = 10 ),
203
191
)
204
192
205
193
assert np .isclose (results .constant , t1 , 50 )
0 commit comments