From 633cfa657bb0f23c3e70bdbe1ef29e7413a1a97a Mon Sep 17 00:00:00 2001 From: Eliott Rosenberg Date: Sat, 9 Mar 2024 20:48:49 -0800 Subject: [PATCH 01/13] T1 experiment: add A and B constants to fit, make wait times log-spaced --- .../cirq/experiments/t1_decay_experiment.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/cirq-core/cirq/experiments/t1_decay_experiment.py b/cirq-core/cirq/experiments/t1_decay_experiment.py index 0d44db7b412..73be6cdb009 100644 --- a/cirq-core/cirq/experiments/t1_decay_experiment.py +++ b/cirq-core/cirq/experiments/t1_decay_experiment.py @@ -77,7 +77,12 @@ def t1_decay( var = sympy.Symbol('delay_ns') - sweep = study.Linspace(var, start=min_delay_nanos, stop=max_delay_nanos, length=num_points) + if min_delay_nanos == 0: + min_delay_nanos = 0.4 + sweep_vals_ns = np.unique( + np.logspace(np.log10(min_delay_nanos), np.log10(max_delay_nanos), num_points, dtype=int) + ) + sweep = study.Points(var, sweep_vals_ns) circuit = circuits.Circuit( ops.X(qubit), ops.wait(qubit, nanos=var), ops.measure(qubit, key='output') @@ -118,8 +123,8 @@ def data(self) -> pd.DataFrame: def constant(self) -> float: """The t1 decay constant.""" - def exp_decay(x, t1): - return np.exp(-x / t1) + def exp_decay(x, t1, A, B): + return A * np.exp(-x / t1) + B xs = self._data['delay_ns'] ts = self._data['true_count'] @@ -132,7 +137,8 @@ def exp_decay(x, t1): # Fit to exponential decay to find the t1 constant try: - popt, _ = optimize.curve_fit(exp_decay, xs, probs, p0=[t1_guess]) + popt, _ = optimize.curve_fit(exp_decay, xs, probs, p0=[t1_guess, 1.0, 0.0]) + self.popt = popt t1 = popt[0] return t1 except RuntimeError: @@ -166,7 +172,9 @@ def plot( ax.plot(xs, ts / (fs + ts), 'ro-', **plot_kwargs) if include_fit and not np.isnan(self.constant): - ax.plot(xs, np.exp(-xs / self.constant), label='curve fit') + t1 = self.constant + t1, A, B = self.popt + ax.plot(xs, A * np.exp(-xs / t1) + B, label='curve fit') plt.legend() ax.set_xlabel(r"Delay between initialization and measurement (nanoseconds)") From 8008823e8b0cda51f792cecf0fcce13d08dedb92 Mon Sep 17 00:00:00 2001 From: Eliott Rosenberg Date: Sat, 9 Mar 2024 20:53:20 -0800 Subject: [PATCH 02/13] lowercase variable names --- cirq-core/cirq/experiments/t1_decay_experiment.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cirq-core/cirq/experiments/t1_decay_experiment.py b/cirq-core/cirq/experiments/t1_decay_experiment.py index 73be6cdb009..12bbe234538 100644 --- a/cirq-core/cirq/experiments/t1_decay_experiment.py +++ b/cirq-core/cirq/experiments/t1_decay_experiment.py @@ -123,8 +123,8 @@ def data(self) -> pd.DataFrame: def constant(self) -> float: """The t1 decay constant.""" - def exp_decay(x, t1, A, B): - return A * np.exp(-x / t1) + B + def exp_decay(x, t1, a, b): + return a * np.exp(-x / t1) + b xs = self._data['delay_ns'] ts = self._data['true_count'] @@ -173,8 +173,8 @@ def plot( if include_fit and not np.isnan(self.constant): t1 = self.constant - t1, A, B = self.popt - ax.plot(xs, A * np.exp(-xs / t1) + B, label='curve fit') + t1, a, b = self.popt + ax.plot(xs, a * np.exp(-xs / t1) + b, label='curve fit') plt.legend() ax.set_xlabel(r"Delay between initialization and measurement (nanoseconds)") From b8264b9db79876a83edf74c451035cbf9675dc98 Mon Sep 17 00:00:00 2001 From: Eliott Rosenberg Date: Sat, 9 Mar 2024 21:39:03 -0800 Subject: [PATCH 03/13] update tests --- cirq-core/cirq/experiments/t1_decay_experiment_test.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cirq-core/cirq/experiments/t1_decay_experiment_test.py b/cirq-core/cirq/experiments/t1_decay_experiment_test.py index 64d220dd5c1..69685991f89 100644 --- a/cirq-core/cirq/experiments/t1_decay_experiment_test.py +++ b/cirq-core/cirq/experiments/t1_decay_experiment_test.py @@ -121,7 +121,7 @@ def test_all_on_results(): data=pd.DataFrame( columns=['delay_ns', 'false_count', 'true_count'], index=range(4), - data=[[100.0, 0, 10], [400.0, 0, 10], [700.0, 0, 10], [1000.0, 0, 10]], + data=[[100.0, 0, 10], [215.0, 0, 10], [464.0, 0, 10], [1000.0, 0, 10]], ) ) @@ -139,7 +139,7 @@ def test_all_off_results(): data=pd.DataFrame( columns=['delay_ns', 'false_count', 'true_count'], index=range(4), - data=[[100.0, 10, 0], [400.0, 10, 0], [700.0, 10, 0], [1000.0, 10, 0]], + data=[[100.0, 10, 0], [215.0, 10, 0], [464.0, 10, 0], [1000.0, 10, 0]], ) ) @@ -150,7 +150,7 @@ def test_curve_fit_plot_works(): data=pd.DataFrame( columns=['delay_ns', 'false_count', 'true_count'], index=range(4), - data=[[100.0, 6, 4], [400.0, 10, 0], [700.0, 10, 0], [1000.0, 10, 0]], + data=[[100.0, 6, 4], [215.0, 10, 0], [464.0, 10, 0], [1000.0, 10, 0]], ) ) @@ -163,7 +163,7 @@ def test_curve_fit_plot_warning(): data=pd.DataFrame( columns=['delay_ns', 'false_count', 'true_count'], index=range(4), - data=[[100.0, 10, 0], [400.0, 10, 0], [700.0, 10, 0], [1000.0, 10, 0]], + data=[[100.0, 10, 0], [215.0, 10, 0], [464.0, 10, 0], [1000.0, 10, 0]], ) ) From 07fcfacc395d8c62228ce281a9fe862018006d3f Mon Sep 17 00:00:00 2001 From: Eliott Rosenberg Date: Sat, 9 Mar 2024 21:41:44 -0800 Subject: [PATCH 04/13] update tests --- .../cirq/experiments/t1_decay_experiment_test.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cirq-core/cirq/experiments/t1_decay_experiment_test.py b/cirq-core/cirq/experiments/t1_decay_experiment_test.py index 69685991f89..7bca529f648 100644 --- a/cirq-core/cirq/experiments/t1_decay_experiment_test.py +++ b/cirq-core/cirq/experiments/t1_decay_experiment_test.py @@ -61,7 +61,7 @@ def test_result_eq(): eq.make_equality_group( lambda: cirq.experiments.T1DecayResult( data=pd.DataFrame( - columns=['delay_ns', 'false_count', 'true_count'], index=[0], data=[[100.0, 2, 8]] + columns=['delay_ns', 'false_count', 'true_count'], index=[0], data=[[100, 2, 8]] ) ) ) @@ -103,7 +103,7 @@ def noisy_moment(self, moment, system_qubits): data=pd.DataFrame( columns=['delay_ns', 'false_count', 'true_count'], index=range(4), - data=[[100.0, 0, 10], [400.0, 0, 10], [700.0, 10, 0], [1000.0, 10, 0]], + data=[[100, 0, 10], [400, 0, 10], [700, 10, 0], [1000, 10, 0]], ) ) @@ -121,7 +121,7 @@ def test_all_on_results(): data=pd.DataFrame( columns=['delay_ns', 'false_count', 'true_count'], index=range(4), - data=[[100.0, 0, 10], [215.0, 0, 10], [464.0, 0, 10], [1000.0, 0, 10]], + data=[[100, 0, 10], [215, 0, 10], [464, 0, 10], [1000, 0, 10]], ) ) @@ -139,7 +139,7 @@ def test_all_off_results(): data=pd.DataFrame( columns=['delay_ns', 'false_count', 'true_count'], index=range(4), - data=[[100.0, 10, 0], [215.0, 10, 0], [464.0, 10, 0], [1000.0, 10, 0]], + data=[[100, 10, 0], [215, 10, 0], [464, 10, 0], [1000, 10, 0]], ) ) @@ -150,7 +150,7 @@ def test_curve_fit_plot_works(): data=pd.DataFrame( columns=['delay_ns', 'false_count', 'true_count'], index=range(4), - data=[[100.0, 6, 4], [215.0, 10, 0], [464.0, 10, 0], [1000.0, 10, 0]], + data=[[100, 6, 4], [215, 10, 0], [464, 10, 0], [1000, 10, 0]], ) ) @@ -163,7 +163,7 @@ def test_curve_fit_plot_warning(): data=pd.DataFrame( columns=['delay_ns', 'false_count', 'true_count'], index=range(4), - data=[[100.0, 10, 0], [215.0, 10, 0], [464.0, 10, 0], [1000.0, 10, 0]], + data=[[100, 10, 0], [215, 10, 0], [464, 10, 0], [1000, 10, 0]], ) ) From e73d8df4a84028057b25cc06cc0c3c00c82931bd Mon Sep 17 00:00:00 2001 From: Eliott Rosenberg Date: Sat, 9 Mar 2024 21:43:12 -0800 Subject: [PATCH 05/13] update tests --- cirq-core/cirq/experiments/t1_decay_experiment_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cirq-core/cirq/experiments/t1_decay_experiment_test.py b/cirq-core/cirq/experiments/t1_decay_experiment_test.py index 7bca529f648..aac8e0f3172 100644 --- a/cirq-core/cirq/experiments/t1_decay_experiment_test.py +++ b/cirq-core/cirq/experiments/t1_decay_experiment_test.py @@ -25,7 +25,7 @@ def test_init_result(): data = pd.DataFrame( columns=['delay_ns', 'false_count', 'true_count'], index=range(2), - data=[[100.0, 0, 10], [1000.0, 10, 0]], + data=[[100, 0, 10], [1000, 10, 0]], ) result = cirq.experiments.T1DecayResult(data) assert result.data is data @@ -103,7 +103,7 @@ def noisy_moment(self, moment, system_qubits): data=pd.DataFrame( columns=['delay_ns', 'false_count', 'true_count'], index=range(4), - data=[[100, 0, 10], [400, 0, 10], [700, 10, 0], [1000, 10, 0]], + data=[[100, 0, 10], [215, 0, 10], [700, 10, 0], [1000, 10, 0]], ) ) From c8041ccf53df3dcd85bc6438c670bc588f05637b Mon Sep 17 00:00:00 2001 From: Eliott Rosenberg Date: Sat, 9 Mar 2024 22:08:53 -0800 Subject: [PATCH 06/13] update tests --- .../cirq/experiments/t1_decay_experiment_test.py | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/cirq-core/cirq/experiments/t1_decay_experiment_test.py b/cirq-core/cirq/experiments/t1_decay_experiment_test.py index aac8e0f3172..3e7797627b5 100644 --- a/cirq-core/cirq/experiments/t1_decay_experiment_test.py +++ b/cirq-core/cirq/experiments/t1_decay_experiment_test.py @@ -103,7 +103,7 @@ def noisy_moment(self, moment, system_qubits): data=pd.DataFrame( columns=['delay_ns', 'false_count', 'true_count'], index=range(4), - data=[[100, 0, 10], [215, 0, 10], [700, 10, 0], [1000, 10, 0]], + data=[[100, 0, 10], [215, 0, 10], [464, 10, 0], [1000, 10, 0]], ) ) @@ -157,20 +157,6 @@ def test_curve_fit_plot_works(): good_fit.plot(include_fit=True) -@pytest.mark.usefixtures('closefigures') -def test_curve_fit_plot_warning(): - bad_fit = cirq.experiments.T1DecayResult( - data=pd.DataFrame( - columns=['delay_ns', 'false_count', 'true_count'], - index=range(4), - data=[[100, 10, 0], [215, 10, 0], [464, 10, 0], [1000, 10, 0]], - ) - ) - - with pytest.warns(RuntimeWarning, match='Optimal parameters could not be found for curve fit'): - bad_fit.plot(include_fit=True) - - @pytest.mark.parametrize('t1', [200, 500, 700]) def test_noise_model_continous(t1): class GradualDecay(cirq.NoiseModel): From 3c6591e30a127126ad6b2e409420424aee1e9f0c Mon Sep 17 00:00:00 2001 From: Eliott Rosenberg Date: Sun, 10 Mar 2024 13:10:01 -0700 Subject: [PATCH 07/13] update tests --- cirq-core/cirq/experiments/t1_decay_experiment_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cirq-core/cirq/experiments/t1_decay_experiment_test.py b/cirq-core/cirq/experiments/t1_decay_experiment_test.py index 3e7797627b5..f488c4aaaf4 100644 --- a/cirq-core/cirq/experiments/t1_decay_experiment_test.py +++ b/cirq-core/cirq/experiments/t1_decay_experiment_test.py @@ -103,7 +103,7 @@ def noisy_moment(self, moment, system_qubits): data=pd.DataFrame( columns=['delay_ns', 'false_count', 'true_count'], index=range(4), - data=[[100, 0, 10], [215, 0, 10], [464, 10, 0], [1000, 10, 0]], + data=[[100, 0, 10], [215, 0, 10], [464, 10, 10], [1000, 10, 0]], ) ) From 5bbc32d633e6c92f3f1f1006901bbf4ef1ca4fdc Mon Sep 17 00:00:00 2001 From: Eliott Rosenberg Date: Sun, 10 Mar 2024 13:12:32 -0700 Subject: [PATCH 08/13] update tests --- cirq-core/cirq/experiments/t1_decay_experiment_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cirq-core/cirq/experiments/t1_decay_experiment_test.py b/cirq-core/cirq/experiments/t1_decay_experiment_test.py index f488c4aaaf4..ae50e19a2dc 100644 --- a/cirq-core/cirq/experiments/t1_decay_experiment_test.py +++ b/cirq-core/cirq/experiments/t1_decay_experiment_test.py @@ -103,7 +103,7 @@ def noisy_moment(self, moment, system_qubits): data=pd.DataFrame( columns=['delay_ns', 'false_count', 'true_count'], index=range(4), - data=[[100, 0, 10], [215, 0, 10], [464, 10, 10], [1000, 10, 0]], + data=[[100, 0, 10], [215, 0, 10], [464, 0, 10], [1000, 10, 0]], ) ) From d795b390ed89ff884aec00deaaa57cff99c1851d Mon Sep 17 00:00:00 2001 From: Eliott Rosenberg Date: Sun, 10 Mar 2024 13:39:18 -0700 Subject: [PATCH 09/13] update tests --- cirq-core/cirq/experiments/t1_decay_experiment_test.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cirq-core/cirq/experiments/t1_decay_experiment_test.py b/cirq-core/cirq/experiments/t1_decay_experiment_test.py index ae50e19a2dc..ac6838e2733 100644 --- a/cirq-core/cirq/experiments/t1_decay_experiment_test.py +++ b/cirq-core/cirq/experiments/t1_decay_experiment_test.py @@ -53,7 +53,7 @@ def noisy_moment(self, moment, system_qubits): repetitions=10, max_delay=cirq.Duration(nanos=500), ) - results.plot() + results.plot(include_fit=True) def test_result_eq(): @@ -182,10 +182,10 @@ def noisy_moment(self, moment, system_qubits): results = cirq.experiments.t1_decay( sampler=cirq.DensityMatrixSimulator(noise=GradualDecay(t1)), qubit=cirq.GridQubit(0, 0), - num_points=4, + num_points=10, repetitions=10, - min_delay=cirq.Duration(nanos=100), - max_delay=cirq.Duration(micros=1), + min_delay=cirq.Duration(nanos=1), + max_delay=cirq.Duration(micros=10), ) assert np.isclose(results.constant, t1, 50) From f19c740303598f85e043b4c339d7c229180e05eb Mon Sep 17 00:00:00 2001 From: Eliott Rosenberg Date: Mon, 11 Mar 2024 10:56:34 -0700 Subject: [PATCH 10/13] informative assert statements in tests --- cirq-core/cirq/experiments/t1_decay_experiment_test.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cirq-core/cirq/experiments/t1_decay_experiment_test.py b/cirq-core/cirq/experiments/t1_decay_experiment_test.py index ac6838e2733..f81c55f74b0 100644 --- a/cirq-core/cirq/experiments/t1_decay_experiment_test.py +++ b/cirq-core/cirq/experiments/t1_decay_experiment_test.py @@ -117,13 +117,14 @@ def test_all_on_results(): min_delay=cirq.Duration(nanos=100), max_delay=cirq.Duration(micros=1), ) - assert results == cirq.experiments.T1DecayResult( + desired = cirq.experiments.T1DecayResult( data=pd.DataFrame( columns=['delay_ns', 'false_count', 'true_count'], index=range(4), data=[[100, 0, 10], [215, 0, 10], [464, 0, 10], [1000, 0, 10]], ) ) + assert results == desired, f'{results.data=} {desired.data=}' def test_all_off_results(): @@ -135,13 +136,14 @@ def test_all_off_results(): min_delay=cirq.Duration(nanos=100), max_delay=cirq.Duration(micros=1), ) - assert results == cirq.experiments.T1DecayResult( + desired = cirq.experiments.T1DecayResult( data=pd.DataFrame( columns=['delay_ns', 'false_count', 'true_count'], index=range(4), data=[[100, 10, 0], [215, 10, 0], [464, 10, 0], [1000, 10, 0]], ) ) + assert results == desired, f'{results.data=} {desired.data=}' @pytest.mark.usefixtures('closefigures') From ea4e8b90137f9588fd6eb722d7f09388cc00a281 Mon Sep 17 00:00:00 2001 From: Eliott Rosenberg Date: Mon, 11 Mar 2024 23:05:48 -0700 Subject: [PATCH 11/13] use float wait time --- cirq-core/cirq/experiments/t1_decay_experiment.py | 2 +- .../cirq/experiments/t1_decay_experiment_test.py | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cirq-core/cirq/experiments/t1_decay_experiment.py b/cirq-core/cirq/experiments/t1_decay_experiment.py index 12bbe234538..744ee4fc5f1 100644 --- a/cirq-core/cirq/experiments/t1_decay_experiment.py +++ b/cirq-core/cirq/experiments/t1_decay_experiment.py @@ -80,7 +80,7 @@ def t1_decay( if min_delay_nanos == 0: min_delay_nanos = 0.4 sweep_vals_ns = np.unique( - np.logspace(np.log10(min_delay_nanos), np.log10(max_delay_nanos), num_points, dtype=int) + np.round(np.logspace(np.log10(min_delay_nanos), np.log10(max_delay_nanos), num_points)) ) sweep = study.Points(var, sweep_vals_ns) diff --git a/cirq-core/cirq/experiments/t1_decay_experiment_test.py b/cirq-core/cirq/experiments/t1_decay_experiment_test.py index f81c55f74b0..acbd7526433 100644 --- a/cirq-core/cirq/experiments/t1_decay_experiment_test.py +++ b/cirq-core/cirq/experiments/t1_decay_experiment_test.py @@ -25,7 +25,7 @@ def test_init_result(): data = pd.DataFrame( columns=['delay_ns', 'false_count', 'true_count'], index=range(2), - data=[[100, 0, 10], [1000, 10, 0]], + data=[[100.0, 0, 10], [1000.0, 10, 0]], ) result = cirq.experiments.T1DecayResult(data) assert result.data is data @@ -103,7 +103,7 @@ def noisy_moment(self, moment, system_qubits): data=pd.DataFrame( columns=['delay_ns', 'false_count', 'true_count'], index=range(4), - data=[[100, 0, 10], [215, 0, 10], [464, 0, 10], [1000, 10, 0]], + data=[[100.0, 0, 10], [215.0, 0, 10], [464.0, 0, 10], [1000.0, 10, 0]], ) ) @@ -121,7 +121,7 @@ def test_all_on_results(): data=pd.DataFrame( columns=['delay_ns', 'false_count', 'true_count'], index=range(4), - data=[[100, 0, 10], [215, 0, 10], [464, 0, 10], [1000, 0, 10]], + data=[[100.0, 0, 10], [215.0, 0, 10], [464.0, 0, 10], [1000.0, 0, 10]], ) ) assert results == desired, f'{results.data=} {desired.data=}' @@ -140,7 +140,7 @@ def test_all_off_results(): data=pd.DataFrame( columns=['delay_ns', 'false_count', 'true_count'], index=range(4), - data=[[100, 10, 0], [215, 10, 0], [464, 10, 0], [1000, 10, 0]], + data=[[100.0, 10, 0], [215.0, 10, 0], [464.0, 10, 0], [1000.0, 10, 0]], ) ) assert results == desired, f'{results.data=} {desired.data=}' @@ -152,14 +152,14 @@ def test_curve_fit_plot_works(): data=pd.DataFrame( columns=['delay_ns', 'false_count', 'true_count'], index=range(4), - data=[[100, 6, 4], [215, 10, 0], [464, 10, 0], [1000, 10, 0]], + data=[[100.0, 6, 4], [215.0, 10, 0], [464.0, 10, 0], [1000.0, 10, 0]], ) ) good_fit.plot(include_fit=True) -@pytest.mark.parametrize('t1', [200, 500, 700]) +@pytest.mark.parametrize('t1', [200.0, 500.0, 700.0]) def test_noise_model_continous(t1): class GradualDecay(cirq.NoiseModel): def __init__(self, t1: float): From a6fdb92c164af14d32bb67ca122fea0f584b222f Mon Sep 17 00:00:00 2001 From: Eliott Rosenberg Date: Mon, 11 Mar 2024 23:20:56 -0700 Subject: [PATCH 12/13] typecheck --- cirq-core/cirq/experiments/t1_decay_experiment.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cirq-core/cirq/experiments/t1_decay_experiment.py b/cirq-core/cirq/experiments/t1_decay_experiment.py index 744ee4fc5f1..01af366d1f4 100644 --- a/cirq-core/cirq/experiments/t1_decay_experiment.py +++ b/cirq-core/cirq/experiments/t1_decay_experiment.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, Optional, Sequence, TYPE_CHECKING, cast import warnings import pandas as pd @@ -82,7 +82,7 @@ def t1_decay( sweep_vals_ns = np.unique( np.round(np.logspace(np.log10(min_delay_nanos), np.log10(max_delay_nanos), num_points)) ) - sweep = study.Points(var, sweep_vals_ns) + sweep = study.Points(var, cast(Sequence[float], sweep_vals_ns)) circuit = circuits.Circuit( ops.X(qubit), ops.wait(qubit, nanos=var), ops.measure(qubit, key='output') From 3c107ecafe713a8cecafba4c5bda12374caaf4db Mon Sep 17 00:00:00 2001 From: Eliott Rosenberg Date: Tue, 12 Mar 2024 23:29:18 -0700 Subject: [PATCH 13/13] nits --- cirq-core/cirq/experiments/t1_decay_experiment.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cirq-core/cirq/experiments/t1_decay_experiment.py b/cirq-core/cirq/experiments/t1_decay_experiment.py index 01af366d1f4..a8ee85e70b5 100644 --- a/cirq-core/cirq/experiments/t1_decay_experiment.py +++ b/cirq-core/cirq/experiments/t1_decay_experiment.py @@ -137,9 +137,8 @@ def exp_decay(x, t1, a, b): # Fit to exponential decay to find the t1 constant try: - popt, _ = optimize.curve_fit(exp_decay, xs, probs, p0=[t1_guess, 1.0, 0.0]) - self.popt = popt - t1 = popt[0] + self.popt, _ = optimize.curve_fit(exp_decay, xs, probs, p0=[t1_guess, 1.0, 0.0]) + t1 = self.popt[0] return t1 except RuntimeError: warnings.warn("Optimal parameters could not be found for curve fit", RuntimeWarning)