@@ -53,15 +53,15 @@ def noisy_moment(self, moment, system_qubits):
5353 repetitions = 10 ,
5454 max_delay = cirq .Duration (nanos = 500 ),
5555 )
56- results .plot ()
56+ results .plot (include_fit = True )
5757
5858
5959def test_result_eq ():
6060 eq = cirq .testing .EqualsTester ()
6161 eq .make_equality_group (
6262 lambda : cirq .experiments .T1DecayResult (
6363 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 ]]
6565 )
6666 )
6767 )
@@ -103,7 +103,7 @@ def noisy_moment(self, moment, system_qubits):
103103 data = pd .DataFrame (
104104 columns = ['delay_ns' , 'false_count' , 'true_count' ],
105105 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 ]],
107107 )
108108 )
109109
@@ -117,13 +117,14 @@ def test_all_on_results():
117117 min_delay = cirq .Duration (nanos = 100 ),
118118 max_delay = cirq .Duration (micros = 1 ),
119119 )
120- assert results = = cirq .experiments .T1DecayResult (
120+ desired = cirq .experiments .T1DecayResult (
121121 data = pd .DataFrame (
122122 columns = ['delay_ns' , 'false_count' , 'true_count' ],
123123 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 ]],
125125 )
126126 )
127+ assert results == desired , f'{ results .data = } { desired .data = } '
127128
128129
129130def test_all_off_results ():
@@ -135,13 +136,14 @@ def test_all_off_results():
135136 min_delay = cirq .Duration (nanos = 100 ),
136137 max_delay = cirq .Duration (micros = 1 ),
137138 )
138- assert results = = cirq .experiments .T1DecayResult (
139+ desired = cirq .experiments .T1DecayResult (
139140 data = pd .DataFrame (
140141 columns = ['delay_ns' , 'false_count' , 'true_count' ],
141142 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 ]],
143144 )
144145 )
146+ assert results == desired , f'{ results .data = } { desired .data = } '
145147
146148
147149@pytest .mark .usefixtures ('closefigures' )
@@ -150,28 +152,14 @@ def test_curve_fit_plot_works():
150152 data = pd .DataFrame (
151153 columns = ['delay_ns' , 'false_count' , 'true_count' ],
152154 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 ]],
154156 )
155157 )
156158
157159 good_fit .plot (include_fit = True )
158160
159161
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 ])
175163def test_noise_model_continous (t1 ):
176164 class GradualDecay (cirq .NoiseModel ):
177165 def __init__ (self , t1 : float ):
@@ -196,10 +184,10 @@ def noisy_moment(self, moment, system_qubits):
196184 results = cirq .experiments .t1_decay (
197185 sampler = cirq .DensityMatrixSimulator (noise = GradualDecay (t1 )),
198186 qubit = cirq .GridQubit (0 , 0 ),
199- num_points = 4 ,
187+ num_points = 10 ,
200188 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 ),
203191 )
204192
205193 assert np .isclose (results .constant , t1 , 50 )
0 commit comments