Skip to content

Commit d3cde71

Browse files
committed
finalize
- small docs fix - lint - reno
1 parent eb22e39 commit d3cde71

File tree

6 files changed

+48
-21
lines changed

6 files changed

+48
-21
lines changed

qiskit_experiments/curve_analysis/base_curve_analysis.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,13 @@ def _default_options(cls) -> Options:
135135
instance that defines the `self.__call__` method.
136136
normalization (bool) : Set ``True`` to normalize y values within range [-1, 1].
137137
Default to ``False``.
138-
p0 (Dict[str, float]): Array-like or dictionary
139-
of initial parameters.
140-
bounds (Dict[str, Tuple[float, float]]): Array-like or dictionary
141-
of (min, max) tuple of fit parameter boundaries.
138+
p0 (Dict[str, float]): Initial guesses for the fit parameters.
139+
The dictionary is keyed on the fit parameter names.
140+
bounds (Dict[str, Tuple[float, float]]): Boundary of fit parameters.
141+
The dictionary is keyed on the fit parameter names and
142+
values are the tuples of (min, max) of each parameter.
143+
curve_fitter_options (Dict[str, Any]) Options that are passed to the
144+
scipy curve fit which performs the least square fitting on the experiment results.
142145
x_key (str): Circuit metadata key representing a scanned value.
143146
result_parameters (List[Union[str, ParameterRepr]): Parameters reported in the
144147
database as a dedicated entry. This is a list of parameter representation
@@ -149,8 +152,6 @@ def _default_options(cls) -> Options:
149152
Representation should be printable in standard output, i.e. no latex syntax.
150153
extra (Dict[str, Any]): A dictionary that is appended to all database entries
151154
as extra information.
152-
curve_fitter_options (Dict[str, Any]) Options that are passed to the
153-
specified curve fitting function.
154155
fixed_parameters (Dict[str, Any]): Fitting model parameters that are fixed
155156
during the curve fitting. This should be provided with default value
156157
keyed on one of the parameter names in the series definition.

qiskit_experiments/curve_analysis/curve_analysis.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,6 @@ def __init__(self):
5959
#: List[CurveData]: Processed experiment data set. For backward compatibility.
6060
self.__processed_data_set = {}
6161

62-
#: List[int]: Index of physical qubits
63-
self._physical_qubits = None
64-
6562
@classmethod
6663
def _fit_params(cls) -> List[str]:
6764
"""Return a list of fitting parameters.
@@ -200,9 +197,7 @@ def _run_analysis(
200197
quality = self._evaluate_quality(fit_data)
201198

202199
# Create analysis results
203-
analysis_results.extend(
204-
self._create_analysis_results(fit_data, quality, **metadata)
205-
)
200+
analysis_results.extend(self._create_analysis_results(fit_data, quality, **metadata))
206201
# calling old extra entry method for backward compatibility
207202
if hasattr(self, "_extra_database_entry"):
208203
warnings.warn(
@@ -331,6 +326,9 @@ def analysis_result_to_repr(result: AnalysisResultData) -> str:
331326
332327
Returns:
333328
String representation of the data.
329+
330+
Raises:
331+
AnalysisError: When the result data is not likely fit parameter.
334332
"""
335333
if not isinstance(result.value, (float, UFloat)):
336334
raise AnalysisError(f"Result data {result.name} is not a valid fit parameter data type.")

qiskit_experiments/curve_analysis/standard_analysis/gaussian.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,10 @@ def _evaluate_quality(self, fit_data: curve.FitData) -> Union[str, None]:
127127
fit_a = fit_data.fitval("a")
128128
fit_b = fit_data.fitval("b")
129129
fit_freq = fit_data.fitval("freq")
130-
fit_kappa = fit_data.fitval("kappa")
130+
fit_sigma = fit_data.fitval("sigma")
131131

132132
snr = abs(fit_a.n) / np.sqrt(abs(np.median(fit_data.y_data) - fit_b.n))
133-
fit_width_ratio = fit_kappa.n / np.ptp(fit_data.x_data)
133+
fit_width_ratio = fit_sigma.n / np.ptp(fit_data.x_data)
134134

135135
criteria = [
136136
fit_data.x_range[0] <= fit_freq.n <= fit_data.x_range[1],

qiskit_experiments/library/characterization/analysis/cr_hamiltonian_analysis.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import qiskit_experiments.curve_analysis as curve
2222

2323
import qiskit_experiments.data_processing as dp
24-
from qiskit_experiments.database_service.device_component import Qubit
2524
from qiskit_experiments.framework import AnalysisResultData
2625

2726

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
developer:
3+
- |
4+
:class:`CurveAnalysis` is now a subclass of :class:`BaseCurveAnalysis`.
5+
This change has been made to introduce multi-grouped curve analysis,
6+
see qiskit-experiments/#737 for details.
7+
8+
According to this update, several protected methods that are
9+
originally designed to be overridden by subclass have been deprecated or upgraded.
10+
Check the following list of changes you may need to upgrade your analysis subclass.
11+
12+
- :meth:`CurveAnalysis._generate_fit_guesses`
13+
14+
The signature of method has been upgraded. Now this method should be called with
15+
``curve_data`` and calling ``self._data()`` to get curve data has been deprecated.
16+
17+
- :meth:`CurveAnalysis._data`
18+
19+
This method has been deprecated.
20+
21+
- :meth:`CurveAnalysis._extra_database_entry`
22+
23+
This method has been deprecated. You can directly override
24+
new method :meth:`CurveAnalysis._create_analysis_results`.
25+
26+
- :class:`FitData`
27+
28+
Fit data dataclass is now created with :attr:`x_data` and :attr:`y_data`
29+
so that you can retrieve the data used for the fitting along with the outcome parameters.
30+
31+
See :ref:`curve_analysis_overview` for the overview of new curve analysis base class.

test/curve_analysis/test_baseclass.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ class TestCurveAnalysisUnit(QiskitExperimentsTestCase):
8181

8282
class TestAnalysis(CurveAnalysis):
8383
"""Fake analysis class for unittest."""
84+
8485
__series__ = [
8586
SeriesDef(
8687
name="curve1",
@@ -136,9 +137,7 @@ def test_data_extraction(self):
136137
xvalues = np.linspace(1.0, 5.0, 10)
137138

138139
analysis = self.TestAnalysis()
139-
analysis.set_options(
140-
data_processor=DataProcessor("counts", [Probability("1")])
141-
)
140+
analysis.set_options(data_processor=DataProcessor("counts", [Probability("1")]))
142141

143142
# data to analyze
144143
test_data0 = simulate_output_data(
@@ -171,9 +170,7 @@ def test_data_extraction_with_subset(self):
171170
xvalues = np.linspace(1.0, 5.0, 10)
172171

173172
analysis = self.TestAnalysis()
174-
analysis.set_options(
175-
data_processor=DataProcessor("counts", [Probability("1")])
176-
)
173+
analysis.set_options(data_processor=DataProcessor("counts", [Probability("1")]))
177174

178175
# data to analyze
179176
test_data0 = simulate_output_data(
@@ -257,6 +254,7 @@ def test_invalid_options(self):
257254

258255
class InvalidClass:
259256
"""Dummy class."""
257+
260258
pass
261259

262260
with self.assertRaises(TypeError):

0 commit comments

Comments
 (0)