diff --git a/qiskit_experiments/curve_analysis/curve_fit.py b/qiskit_experiments/curve_analysis/curve_fit.py index 41d654e308..13045c21e2 100644 --- a/qiskit_experiments/curve_analysis/curve_fit.py +++ b/qiskit_experiments/curve_analysis/curve_fit.py @@ -85,7 +85,7 @@ def curve_fit( upper = [bounds[key][1] for key in param_keys] param_bounds = (lower, upper) else: - param_bounds = None + param_bounds = ([-np.inf] * len(param_keys), [np.inf] * len(param_keys)) # Convert fit function def fit_func(x, *params): @@ -94,7 +94,10 @@ def fit_func(x, *params): else: param_keys = None param_p0 = p0 - param_bounds = bounds + if bounds: + param_bounds = bounds + else: + param_bounds = ([-np.inf] * len(p0), [np.inf] * len(p0)) fit_func = func # Check the degrees of freedom is greater than 0 diff --git a/qiskit_experiments/library/characterization/t1_analysis.py b/qiskit_experiments/library/characterization/t1_analysis.py index 12103883c3..d7addafccc 100644 --- a/qiskit_experiments/library/characterization/t1_analysis.py +++ b/qiskit_experiments/library/characterization/t1_analysis.py @@ -47,11 +47,6 @@ class T1Analysis(BaseAnalysis): - :math:`amplitude\_guess`: Determined by :math:`(y_0 - offset\_guess)` - :math:`offset\_guess`: Determined by the last :math:`y` - :math:`t1\_guess`: Determined by the mean of the data points - - Bounds - - :math:`amplitude\_bounds`: [0, 1] - - :math:`offset\_bounds`: [0, 1] - - :math:`t1\_bounds`: [0, infinity] """ @classmethod @@ -60,9 +55,6 @@ def _default_options(cls): t1_guess=None, amplitude_guess=None, offset_guess=None, - t1_bounds=None, - amplitude_bounds=None, - offset_bounds=None, ) # pylint: disable=arguments-differ @@ -72,9 +64,6 @@ def _run_analysis( t1_guess=None, amplitude_guess=None, offset_guess=None, - t1_bounds=None, - amplitude_bounds=None, - offset_bounds=None, plot=True, ax=None, ) -> Tuple[List[CurveAnalysisResultData], List["matplotlib.figure.Figure"]]: @@ -87,11 +76,6 @@ def _run_analysis( amplitude_guess (float): Optional, an initial guess of the coefficient of the exponent offset_guess (float): Optional, an initial guess of the offset - t1_bounds (list of two floats): Optional, lower bound and upper bound to T1 - amplitude_bounds (list of two floats): Optional, lower bound and upper - bound to the amplitude - offset_bounds (list of two floats): Optional, lower bound and upper - bound to the offset plot (bool): Generator plot of exponential fit. ax (AxesSubplot): Optional, axes to add figure to. @@ -120,20 +104,13 @@ def _run_analysis( offset_guess = ydata[-1] if amplitude_guess is None: amplitude_guess = ydata[0] - offset_guess - if t1_bounds is None: - t1_bounds = [0, np.inf] - if amplitude_bounds is None: - amplitude_bounds = [0, 1] - if offset_bounds is None: - offset_bounds = [0, 1] # Perform fit def fit_fun(x, a, tau, c): return a * np.exp(-x / tau) + c init = {"a": amplitude_guess, "tau": t1_guess, "c": offset_guess} - bounds = {"a": amplitude_bounds, "tau": t1_bounds, "c": offset_bounds} - fit_result = curve_fit(fit_fun, xdata, ydata, init, sigma=sigma, bounds=bounds) + fit_result = curve_fit(fit_fun, xdata, ydata, init, sigma=sigma) result_data = { "value": fit_result["popt"][1], diff --git a/test/test_t1.py b/test/test_t1.py index 0227a576b2..68f81e7f19 100644 --- a/test/test_t1.py +++ b/test/test_t1.py @@ -87,9 +87,9 @@ def test_t1_parallel_different_analysis_options(self): delays = list(range(1, 40, 3)) exp0 = T1(0, delays) - exp0.set_analysis_options(t1_bounds=[10, 30]) + exp0.set_analysis_options(t1_guess=30) exp1 = T1(1, delays) - exp1.set_analysis_options(t1_bounds=[100, 200]) + exp1.set_analysis_options(t1_guess=1000000) par_exp = ParallelExperiment([exp0, exp1]) res = par_exp.run(T1Backend([t1, t1])) @@ -101,7 +101,7 @@ def test_t1_parallel_different_analysis_options(self): self.assertEqual(sub_res[0].quality, "good") self.assertAlmostEqual(sub_res[0].data()["value"], t1, delta=3) - self.assertFalse(sub_res[1].data()["success"]) + self.assertEqual(sub_res[1].quality, "bad") def test_t1_analysis(self): """