diff --git a/qiskit_experiments/curve_analysis/__init__.py b/qiskit_experiments/curve_analysis/__init__.py index cbc9bcac55..523fbebb69 100644 --- a/qiskit_experiments/curve_analysis/__init__.py +++ b/qiskit_experiments/curve_analysis/__init__.py @@ -312,7 +312,7 @@ class AnalysisB(CurveAnalysis): compute custom quantities based on the raw fit parameters. See :ref:`curve_analysis_results` for details. Afterwards, the analysis draws several curves in the Matplotlib figure. -User can set custom drawer to the option ``curve_plotter``. +User can set custom drawer to the option ``curve_drawer``. The drawer defaults to the :class:`MplCurveDrawer`. Finally, it returns the list of created analysis results and Matplotlib figure. diff --git a/qiskit_experiments/curve_analysis/base_curve_analysis.py b/qiskit_experiments/curve_analysis/base_curve_analysis.py index 74d52a38cf..dc6882dd21 100644 --- a/qiskit_experiments/curve_analysis/base_curve_analysis.py +++ b/qiskit_experiments/curve_analysis/base_curve_analysis.py @@ -111,14 +111,14 @@ def parameters(self) -> List[str]: @property def drawer(self) -> BaseCurveDrawer: """A short-cut for curve drawer instance.""" - return self._options.curve_plotter + return self._options.curve_drawer @classmethod def _default_options(cls) -> Options: """Return default analysis options. Analysis Options: - curve_plotter (BaseCurveDrawer): A curve drawer instance to visualize + curve_drawer (BaseCurveDrawer): A curve drawer instance to visualize the analysis result. plot_raw_data (bool): Set ``True`` to draw processed data points, dataset without formatting, on canvas. This is ``False`` by default. @@ -156,7 +156,7 @@ def _default_options(cls) -> Options: """ options = super()._default_options() - options.curve_plotter = MplCurveDrawer() + options.curve_drawer = MplCurveDrawer() options.plot_raw_data = False options.plot = True options.return_fit_parameters = True @@ -173,7 +173,7 @@ def _default_options(cls) -> Options: # Set automatic validator for particular option values options.set_validator(field="data_processor", validator_value=DataProcessor) - options.set_validator(field="curve_plotter", validator_value=BaseCurveDrawer) + options.set_validator(field="curve_drawer", validator_value=BaseCurveDrawer) return options @@ -187,23 +187,25 @@ def set_options(self, **fields): KeyError: When removed option ``curve_fitter`` is set. """ # TODO remove this in Qiskit Experiments v0.4 - if "curve_plotter" in fields and isinstance(fields["curve_plotter"], str): - plotter_str = fields["curve_plotter"] + if "curve_plotter" in fields: warnings.warn( - f"The curve plotter '{plotter_str}' has been deprecated. " - "The option is replaced with 'MplCurveDrawer' instance. " + f"The analysis option 'curve_plotter' has been deprecated. " + "The option is replaced with 'curve_drawer' that takes 'MplCurveDrawer' instance. " "If this is a loaded analysis, please save this instance again to update option value. " - "This warning will be removed with backport in Qiskit Experiments 0.4.", + "The 'curve_plotter' argument along with this warning will be removed " + "in Qiskit Experiments 0.4.", DeprecationWarning, stacklevel=2, ) - fields["curve_plotter"] = MplCurveDrawer() + del fields["curve_plotter"] if "curve_fitter" in fields: warnings.warn( "Setting curve fitter to analysis options has been deprecated and " "the option has been removed. The fitter setting is dropped. " - "Now you can directly override '_run_curve_fit' method to apply custom fitter.", + "Now you can directly override '_run_curve_fit' method to apply custom fitter. " + "The `curve_fitter` argument along with this warning will be removed " + "in Qiskit Experiments 0.4.", DeprecationWarning, stacklevel=2, ) @@ -217,7 +219,8 @@ def set_options(self, **fields): f"Option(s) {deprecated} have been moved to draw_options and will be removed soon. " "Use self.drawer.set_options instead. " "If this is a loaded analysis, please save this instance again to update option value. " - "This warning will be removed with backport in Qiskit Experiments 0.4.", + "These arguments along with this warning will be removed " + "in Qiskit Experiments 0.4.", DeprecationWarning, stacklevel=2, ) diff --git a/qiskit_experiments/curve_analysis/curve_data.py b/qiskit_experiments/curve_analysis/curve_data.py index cf3ff23368..32e56b50cb 100644 --- a/qiskit_experiments/curve_analysis/curve_data.py +++ b/qiskit_experiments/curve_analysis/curve_data.py @@ -27,7 +27,7 @@ class SeriesDef: """A dataclass to describe the definition of the curve. - Args: + Attributes: fit_func: A callable that defines the fit model of this curve. The argument names in the callable are parsed to create the fit parameter list, which will appear in the analysis results. The first argument should be ``x`` that represents @@ -78,7 +78,7 @@ class CurveData: This dataset can consist of X, Y values from multiple series. To extract curve data of the particular series, :meth:`get_subset_of` can be used. - Args: + Attributes: x: X-values that experiment sweeps. y: Y-values that observed and processed by the data processor. y_err: Uncertainty of the Y-values which is created by the data processor. @@ -130,7 +130,7 @@ def get_subset_of(self, index: Union[str, int]) -> "CurveData": class FitData: """A dataclass to store the outcome of the fitting. - Args: + Attributes: popt: List of optimal parameter values with uncertainties if available. popt_keys: List of parameter names being fit. pcov: Covariance matrix from the least square fitting. @@ -182,7 +182,7 @@ def fitval(self, key: str) -> uncertainties.UFloat: class ParameterRepr: """Detailed description of fitting parameter. - Args: + Attributes: name: Original name of the fit parameter being defined in the fit model. repr: Optional. Human-readable parameter name shown in the analysis result and in the figure. unit: Optional. Physical unit of this parameter if applicable. diff --git a/qiskit_experiments/curve_analysis/standard_analysis/error_amplification_analysis.py b/qiskit_experiments/curve_analysis/standard_analysis/error_amplification_analysis.py index 4acc28fe50..a06af6d50c 100644 --- a/qiskit_experiments/curve_analysis/standard_analysis/error_amplification_analysis.py +++ b/qiskit_experiments/curve_analysis/standard_analysis/error_amplification_analysis.py @@ -106,7 +106,7 @@ def _default_options(cls): considered as good. Defaults to :math:`\pi/2`. """ default_options = super()._default_options() - default_options.curve_plotter.set_options( + default_options.curve_drawer.set_options( xlabel="Number of gates (n)", ylabel="Population", ylim=(0, 1.0), diff --git a/qiskit_experiments/curve_analysis/standard_analysis/gaussian.py b/qiskit_experiments/curve_analysis/standard_analysis/gaussian.py index e59ed3c2f7..2bf57f1c35 100644 --- a/qiskit_experiments/curve_analysis/standard_analysis/gaussian.py +++ b/qiskit_experiments/curve_analysis/standard_analysis/gaussian.py @@ -71,7 +71,7 @@ class GaussianAnalysis(curve.CurveAnalysis): @classmethod def _default_options(cls) -> Options: options = super()._default_options() - options.curve_plotter.set_options( + options.curve_drawer.set_options( xlabel="Frequency", ylabel="Signal (arb. units)", xval_unit="Hz", diff --git a/qiskit_experiments/curve_analysis/standard_analysis/resonance.py b/qiskit_experiments/curve_analysis/standard_analysis/resonance.py index afcfed4b9e..9f3a2cc9b4 100644 --- a/qiskit_experiments/curve_analysis/standard_analysis/resonance.py +++ b/qiskit_experiments/curve_analysis/standard_analysis/resonance.py @@ -71,7 +71,7 @@ class ResonanceAnalysis(curve.CurveAnalysis): @classmethod def _default_options(cls) -> Options: options = super()._default_options() - options.curve_plotter.set_options( + options.curve_drawer.set_options( xlabel="Frequency", ylabel="Signal (arb. units)", xval_unit="Hz", diff --git a/qiskit_experiments/library/characterization/analysis/cr_hamiltonian_analysis.py b/qiskit_experiments/library/characterization/analysis/cr_hamiltonian_analysis.py index bc46c58ec0..bcd5028f7d 100644 --- a/qiskit_experiments/library/characterization/analysis/cr_hamiltonian_analysis.py +++ b/qiskit_experiments/library/characterization/analysis/cr_hamiltonian_analysis.py @@ -196,7 +196,7 @@ class CrossResonanceHamiltonianAnalysis(curve.CurveAnalysis): def _default_options(cls): """Return the default analysis options.""" default_options = super()._default_options() - default_options.curve_plotter.set_options( + default_options.curve_drawer.set_options( subplots=(3, 1), xlabel="Flat top width", ylabel=[ diff --git a/qiskit_experiments/library/characterization/analysis/drag_analysis.py b/qiskit_experiments/library/characterization/analysis/drag_analysis.py index 4e10f39d18..5f3effa7f8 100644 --- a/qiskit_experiments/library/characterization/analysis/drag_analysis.py +++ b/qiskit_experiments/library/characterization/analysis/drag_analysis.py @@ -120,7 +120,7 @@ def _default_options(cls): descriptions of analysis options. """ default_options = super()._default_options() - default_options.curve_plotter.set_options( + default_options.curve_drawer.set_options( xlabel="Beta", ylabel="Signal (arb. units)", ) diff --git a/qiskit_experiments/library/characterization/analysis/ramsey_xy_analysis.py b/qiskit_experiments/library/characterization/analysis/ramsey_xy_analysis.py index b3f87bb3ae..27713212ef 100644 --- a/qiskit_experiments/library/characterization/analysis/ramsey_xy_analysis.py +++ b/qiskit_experiments/library/characterization/analysis/ramsey_xy_analysis.py @@ -95,7 +95,7 @@ def _default_options(cls): descriptions of analysis options. """ default_options = super()._default_options() - default_options.curve_plotter.set_options( + default_options.curve_drawer.set_options( xlabel="Delay", ylabel="Signal (arb. units)", xval_unit="s", diff --git a/qiskit_experiments/library/characterization/analysis/t1_analysis.py b/qiskit_experiments/library/characterization/analysis/t1_analysis.py index a2cd46a1dd..8c2712995a 100644 --- a/qiskit_experiments/library/characterization/analysis/t1_analysis.py +++ b/qiskit_experiments/library/characterization/analysis/t1_analysis.py @@ -30,7 +30,7 @@ class T1Analysis(curve.DecayAnalysis): def _default_options(cls) -> Options: """Default analysis options.""" options = super()._default_options() - options.curve_plotter.set_options( + options.curve_drawer.set_options( xlabel="Delay", ylabel="P(1)", xval_unit="s", diff --git a/qiskit_experiments/library/characterization/analysis/t2hahn_analysis.py b/qiskit_experiments/library/characterization/analysis/t2hahn_analysis.py index c769d88c67..dd03fad838 100644 --- a/qiskit_experiments/library/characterization/analysis/t2hahn_analysis.py +++ b/qiskit_experiments/library/characterization/analysis/t2hahn_analysis.py @@ -34,7 +34,7 @@ class T2HahnAnalysis(curve.DecayAnalysis): def _default_options(cls) -> Options: """Default analysis options.""" options = super()._default_options() - options.curve_plotter.set_options( + options.curve_drawer.set_options( xlabel="Delay", ylabel="P(0)", xval_unit="s", diff --git a/qiskit_experiments/library/characterization/analysis/t2ramsey_analysis.py b/qiskit_experiments/library/characterization/analysis/t2ramsey_analysis.py index 3add85dfd5..8aaca649e1 100644 --- a/qiskit_experiments/library/characterization/analysis/t2ramsey_analysis.py +++ b/qiskit_experiments/library/characterization/analysis/t2ramsey_analysis.py @@ -30,7 +30,7 @@ class T2RamseyAnalysis(curve.DumpedOscillationAnalysis): def _default_options(cls) -> Options: """Default analysis options.""" options = super()._default_options() - options.curve_plotter.set_options( + options.curve_drawer.set_options( xlabel="Delay", ylabel="P(0)", xval_unit="s", diff --git a/qiskit_experiments/library/randomized_benchmarking/rb_analysis.py b/qiskit_experiments/library/randomized_benchmarking/rb_analysis.py index 427851fe11..d54b135789 100644 --- a/qiskit_experiments/library/randomized_benchmarking/rb_analysis.py +++ b/qiskit_experiments/library/randomized_benchmarking/rb_analysis.py @@ -98,7 +98,7 @@ def _default_options(cls): 2Q RB is corected to exclude the deporalization of underlying 1Q channels. """ default_options = super()._default_options() - default_options.curve_plotter.set_options( + default_options.curve_drawer.set_options( xlabel="Clifford Length", ylabel="P(0)", ) diff --git a/releasenotes/notes/cleanup-curve-analysis-96d7ff706cae5b4e.yaml b/releasenotes/notes/cleanup-curve-analysis-96d7ff706cae5b4e.yaml index ece571bcce..1945017bf1 100644 --- a/releasenotes/notes/cleanup-curve-analysis-96d7ff706cae5b4e.yaml +++ b/releasenotes/notes/cleanup-curve-analysis-96d7ff706cae5b4e.yaml @@ -1,6 +1,5 @@ --- -features: - - | +upgrade: :class:`BaseCurveAnalysis` class has been added as a superclass of :class:`CurveAnalysis`. New base class doesn't define the :meth:`_run_analysis` abstract method and it cannot conduct analysis by itself, however it defines several subroutines @@ -8,7 +7,6 @@ features: This allows more flexibility to write custom curve analysis by directly inheriting from the new base class. See :class:`BaseCurveAnalysis` for details. See also qiskit-experiments/#737 for discussion. -upgrade: - | The method :meth:`CurveAnalysis._generate_fit_guesses` has been upgraded with new method signature. Now this method is called with ``curve_data`` argument