Skip to content

Commit ce485f8

Browse files
authored
Remove deprecated code for 0.7 (#1452)
Removes code scheduled for removal in 0.7. For analysis results, `dataframe` is still set to `False` by default as `True` is a breaking change.
1 parent bc0b89e commit ce485f8

32 files changed

+77
-2304
lines changed

docs/conf.py

-8
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ def setup(app):
213213
# Should come up with better way to address this
214214

215215
from qiskit_experiments.curve_analysis import ParameterRepr
216-
from qiskit_experiments.curve_analysis import SeriesDef
217216

218217

219218
def maybe_skip_member(app, what, name, obj, skip, options):
@@ -227,9 +226,6 @@ def maybe_skip_member(app, what, name, obj, skip, options):
227226
"y",
228227
"y_err",
229228
"name",
230-
"filter_kwargs",
231-
"fit_func",
232-
"signature",
233229
"artifact_id",
234230
"artifact_data",
235231
"device_components",
@@ -239,10 +235,6 @@ def maybe_skip_member(app, what, name, obj, skip, options):
239235
skip_members = [
240236
ParameterRepr.repr,
241237
ParameterRepr.unit,
242-
SeriesDef.plot_color,
243-
SeriesDef.plot_symbol,
244-
SeriesDef.model_description,
245-
SeriesDef.canvas,
246238
]
247239
if not skip:
248240
return (name in skip_names or obj in skip_members) and what == "attribute"

docs/howtos/artifacts.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ artifacts as a list of :class:`.ArtifactData` objects accessed by :meth:`.Experi
3636
backend = AerSimulator.from_backend(FakePerth())
3737
exp1 = T1(physical_qubits=[0], delays=np.arange(1e-6, 6e-4, 5e-5))
3838
exp2 = T1(physical_qubits=[1], delays=np.arange(1e-6, 6e-4, 5e-5))
39-
data = ParallelExperiment([exp1, exp2], flatten_results=True).run(backend).block_for_results()
39+
data = ParallelExperiment([exp1, exp2]).run(backend).block_for_results()
4040
data.artifacts()
4141

4242
Artifacts can be accessed using either the artifact ID, which has to be unique in each

docs/manuals/verification/quantum_volume.rst

+4-5
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ Extracting the maximum Quantum Volume.
158158
.. jupyter-execute::
159159

160160
qv_values = [
161-
batch_expdata.child_data(i).analysis_results("quantum_volume").value
161+
batch_expdata.analysis_results("quantum_volume")[i].value
162162
for i in range(batch_exp.num_experiments)
163163
]
164164

@@ -169,10 +169,9 @@ Extracting the maximum Quantum Volume.
169169

170170
for i in range(batch_exp.num_experiments):
171171
print(f"\nComponent experiment {i}")
172-
sub_data = batch_expdata.child_data(i)
173-
display(sub_data.figure(0))
174-
for result in sub_data.analysis_results():
175-
print(result)
172+
display(batch_expdata.figure(i))
173+
for result in batch_expdata.analysis_results():
174+
print(result)
176175

177176
References
178177
----------

docs/manuals/verification/randomized_benchmarking.rst

+1-2
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,7 @@ The EPGs of two-qubit RB are analyzed with the corrected EPC if available.
182182
[
183183
StandardRB((qubit,), lengths_1_qubit, num_samples=num_samples, seed=seed)
184184
for qubit in qubits
185-
],
186-
flatten_results=True,
185+
]
187186
)
188187
expdata_1q = single_exps.run(backend).block_for_results()
189188

docs/tutorials/curve_analysis.rst

+4-9
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ For example, :class:`.StarkRamseyXYAmpScanAnalysis` defines four `series`
343343
labels in its ``data_subfit_map`` option (``Xpos``, ``Ypos``, ``Xneg``,
344344
``Yneg``) but only two models (``FREQpos``, ``FREQneg``) whose names do not
345345
match the series labels.
346-
It does this by overriding the ``CurveData._format_data()`` method and adding
346+
It does this by overriding the ``CurveAnalysis._format_data()`` method and adding
347347
its own series to the :class:`.ScatterTable` with series labels to match its
348348
fit model names (by combining ``Xpos`` and ``Ypos`` series data into a
349349
``FREQpos`` series and similary for the series with names ending with ``neg``).
@@ -400,11 +400,6 @@ See the :doc:`Artifacts how-to </howtos/artifacts>` for more information.
400400
Curve Analysis workflow
401401
-----------------------
402402

403-
.. warning::
404-
405-
:class:`CurveData` dataclass is replaced with :class:`.ScatterTable` dataframe.
406-
This class will be deprecated and removed in the future release.
407-
408403
Typically curve analysis performs fitting as follows.
409404
This workflow is defined in the method :meth:`CurveAnalysis._run_analysis`.
410405

@@ -534,9 +529,9 @@ one can get the list of parameters with the :attr:`CurveAnalysis.parameters`. Ea
534529
boundary value can be a tuple of floats representing minimum and maximum values.
535530

536531
Apart from user provided guesses, the analysis can systematically generate those values
537-
with the method :meth:`_generate_fit_guesses`, which is called with the :class:`CurveData`
538-
dataclass. If the analysis contains multiple model definitions, we can get the subset
539-
of curve data with :meth:`.CurveData.get_subset_of` using the name of the series. A
532+
with the method :meth:`_generate_fit_guesses`, which is called with the :class:`.ScatterTable`
533+
class. If the analysis contains multiple model definitions, we can get the subset
534+
of curve data with :meth:`.ScatterTable.get_subset_of` using the name of the series. A
540535
developer can implement the algorithm to generate initial guesses and boundaries by
541536
using this curve data object, which will be provided to the fitter. Note that there are
542537
several common initial guess estimators available in :mod:`curve_analysis.guess`.

docs/tutorials/getting_started.rst

+6-22
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ simultaneously on the same device:
384384

385385
child_exp1 = T1(physical_qubits=(2,), delays=delays)
386386
child_exp2 = StandardRB(physical_qubits=(3,1), lengths=np.arange(1,100,10), num_samples=2)
387-
parallel_exp = ParallelExperiment([child_exp1, child_exp2], flatten_results=False)
387+
parallel_exp = ParallelExperiment([child_exp1, child_exp2])
388388

389389
Note that when the transpile and run options are set for a composite experiment, the
390390
child experiments's options are also set to the same options recursively. Let's examine
@@ -437,35 +437,19 @@ arbitrarily to make complex composite experiments.
437437
Viewing child experiment data
438438
-----------------------------
439439

440-
The experiment data returned from a composite experiment contains individual analysis
441-
results for each child experiment that can be accessed using
442-
:meth:`~.ExperimentData.child_data`. By default, the parent data object does not contain
443-
analysis results.
440+
The experiment data returned from a composite experiment contains analysis
441+
results for each child experiment in the parent experiment.
444442

445443
.. note::
446444

447-
This behavior will be updated in Qiskit Experiments 0.7.
448445
By default, all analysis results will be stored in the parent data object,
449-
and you need to explicitly set ``flatten_results=False`` to generate child data objects.
450-
451-
.. jupyter-execute::
452-
453-
parallel_data = parallel_exp.run(backend, seed_simulator=101).block_for_results()
454-
455-
for i, sub_data in enumerate(parallel_data.child_data()):
456-
print("Component experiment",i)
457-
display(sub_data.figure(0))
458-
for result in sub_data.analysis_results():
459-
print(result)
460-
461-
If you want the parent data object to contain the analysis results instead, you can set
462-
the ``flatten_results`` flag to true to flatten the results of all component experiments
463-
into one level:
446+
and you need to explicitly set ``flatten_results=False`` to generate child
447+
data objects in the legacy format.
464448

465449
.. jupyter-execute::
466450

467451
parallel_exp = ParallelExperiment(
468-
[T1(physical_qubits=(i,), delays=delays) for i in range(2)], flatten_results=True
452+
[T1(physical_qubits=(i,), delays=delays) for i in range(2)]
469453
)
470454
parallel_data = parallel_exp.run(backend, seed_simulator=101).block_for_results()
471455

qiskit_experiments/curve_analysis/__init__.py

-18
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,10 @@
4040
:toctree: ../stubs/
4141
4242
ScatterTable
43-
SeriesDef
44-
CurveData
4543
CurveFitResult
4644
ParameterRepr
4745
FitOptions
4846
49-
Visualization
50-
=============
51-
52-
.. autosummary::
53-
:toctree: ../stubs/
54-
55-
BaseCurveDrawer
56-
MplCurveDrawer
57-
5847
Standard Analysis Library
5948
=========================
6049
@@ -120,18 +109,14 @@
120109
from .composite_curve_analysis import CompositeCurveAnalysis
121110
from .scatter_table import ScatterTable
122111
from .curve_data import (
123-
CurveData,
124112
CurveFitResult,
125-
FitData,
126113
FitOptions,
127114
ParameterRepr,
128-
SeriesDef,
129115
)
130116
from .curve_fit import (
131117
process_curve_data,
132118
process_multi_curve_data,
133119
)
134-
from .visualization import BaseCurveDrawer, MplCurveDrawer
135120
from . import guess
136121
from . import fit_function
137122
from . import utils
@@ -146,6 +131,3 @@
146131
ErrorAmplificationAnalysis,
147132
BlochTrajectoryAnalysis,
148133
)
149-
150-
# deprecated
151-
from .visualization import plot_curve_fit, plot_errorbar, plot_scatter, FitResultPlotters

qiskit_experiments/curve_analysis/base_curve_analysis.py

-39
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,11 @@
1414
Base class of curve analysis.
1515
"""
1616

17-
import warnings
1817
from abc import ABC, abstractmethod
1918
from typing import Dict, List, Union
2019

2120
import lmfit
2221

23-
from qiskit.utils.deprecation import deprecate_func
24-
2522
from qiskit_experiments.data_processing import DataProcessor
2623
from qiskit_experiments.data_processing.processor_library import get_processor
2724
from qiskit_experiments.framework import (
@@ -31,10 +28,8 @@
3128
Options,
3229
)
3330
from qiskit_experiments.visualization import (
34-
BaseDrawer,
3531
BasePlotter,
3632
CurvePlotter,
37-
LegacyCurveCompatDrawer,
3833
MplDrawer,
3934
)
4035

@@ -130,20 +125,6 @@ def plotter(self) -> BasePlotter:
130125
"""A short-cut to the curve plotter instance."""
131126
return self._options.plotter
132127

133-
@property
134-
@deprecate_func(
135-
since="0.5",
136-
additional_msg="Use `plotter` from the new visualization module.",
137-
removal_timeline="after 0.6",
138-
package_name="qiskit-experiments",
139-
)
140-
def drawer(self) -> BaseDrawer:
141-
"""A short-cut for curve drawer instance, if set. ``None`` otherwise."""
142-
if isinstance(self.plotter.drawer, LegacyCurveCompatDrawer):
143-
return self.plotter.drawer._curve_drawer
144-
else:
145-
return None
146-
147128
@classmethod
148129
def _default_options(cls) -> Options:
149130
"""Return default analysis options.
@@ -159,8 +140,6 @@ def _default_options(cls) -> Options:
159140
not create a figure. This overrides the behavior of ``generate_figures``.
160141
return_fit_parameters (bool): (Deprecated) Set ``True`` to return all fit model parameters
161142
with details of the fit outcome. Default to ``False``.
162-
return_data_points (bool): (Deprecated) Set ``True`` to include in the analysis result
163-
the formatted data points given to the fitter. Default to ``False``.
164143
data_processor (Callable): A callback function to format experiment data.
165144
This can be a :class:`.DataProcessor`
166145
instance that defines the `self.__call__` method.
@@ -211,7 +190,6 @@ def _default_options(cls) -> Options:
211190
options.plot_raw_data = False
212191
options.plot_residuals = False
213192
options.return_fit_parameters = True
214-
options.return_data_points = False
215193
options.data_processor = None
216194
options.normalization = False
217195
options.average_method = "shots_weighted"
@@ -405,20 +383,3 @@ def _initialize(
405383
if not data_processor.is_trained:
406384
data_processor.train(data=experiment_data.data())
407385
self.set_options(data_processor=data_processor)
408-
409-
# Check if a model contains legacy data mapping option.
410-
data_subfit_map = {}
411-
for model in self.models:
412-
if "data_sort_key" in model.opts:
413-
data_subfit_map[model._name] = model.opts["data_sort_key"]
414-
del model.opts["data_sort_key"]
415-
if data_subfit_map:
416-
warnings.warn(
417-
"Setting 'data_sort_key' to an LMFIT model constructor is no longer "
418-
"valid configuration of the model. "
419-
"Use 'data_subfit_map' option in the analysis options. "
420-
"This warning will be dropped in v0.6 along with the support for the "
421-
"'data_sort_key' in the LMFIT model options.",
422-
DeprecationWarning,
423-
)
424-
self.set_options(data_subfit_map=data_subfit_map)

qiskit_experiments/curve_analysis/composite_curve_analysis.py

+1-47
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,15 @@
2222
import numpy as np
2323
import pandas as pd
2424

25-
from qiskit.utils.deprecation import deprecate_func
26-
2725
from qiskit_experiments.framework import (
2826
AnalysisResultData,
2927
BaseAnalysis,
3028
ExperimentData,
3129
Options,
3230
)
3331
from qiskit_experiments.visualization import (
34-
BaseDrawer,
3532
BasePlotter,
3633
CurvePlotter,
37-
LegacyCurveCompatDrawer,
3834
MplDrawer,
3935
)
4036

@@ -76,7 +72,6 @@ class CompositeCurveAnalysis(BaseAnalysis):
7672
for qi in (0, 1):
7773
analysis = curve.OscillationAnalysis(name=f"init{qi}")
7874
analysis.set_options(
79-
return_fit_parameters=["freq"],
8075
filter_data={"init_state": qi},
8176
)
8277
analysis = CompositeCurveAnalysis(analyses=analyses)
@@ -147,20 +142,6 @@ def plotter(self) -> BasePlotter:
147142
"""A short-cut to the plotter instance."""
148143
return self._options.plotter
149144

150-
@property
151-
@deprecate_func(
152-
since="0.5",
153-
additional_msg="Use `plotter` from the new visualization module instead.",
154-
removal_timeline="after 0.6",
155-
package_name="qiskit-experiments",
156-
)
157-
def drawer(self) -> BaseDrawer:
158-
"""A short-cut for curve drawer instance, if set. ``None`` otherwise."""
159-
if hasattr(self._options, "curve_drawer"):
160-
return self._options.curve_drawer
161-
else:
162-
return None
163-
164145
def analyses(
165146
self, index: Optional[Union[str, int]] = None
166147
) -> Union[BaseCurveAnalysis, List[BaseCurveAnalysis]]:
@@ -273,8 +254,6 @@ def _default_options(cls) -> Options:
273254
This is ``True`` by default.
274255
return_fit_parameters (bool): (Deprecated) Set ``True`` to return all fit model parameters
275256
with details of the fit outcome. Default to ``False``.
276-
return_data_points (bool): (Deprecated) Set ``True`` to include in the analysis result
277-
the formatted data points given to the fitter. Default to ``False``.
278257
extra (Dict[str, Any]): A dictionary that is appended to all database entries
279258
as extra information.
280259
"""
@@ -283,7 +262,6 @@ def _default_options(cls) -> Options:
283262
plotter=CurvePlotter(MplDrawer()),
284263
plot=True,
285264
return_fit_parameters=False,
286-
return_data_points=False,
287265
extra={},
288266
)
289267

@@ -293,27 +271,6 @@ def _default_options(cls) -> Options:
293271
return options
294272

295273
def set_options(self, **fields):
296-
# TODO remove this in Qiskit Experiments 0.6
297-
if "curve_drawer" in fields:
298-
warnings.warn(
299-
"The option 'curve_drawer' is replaced with 'plotter'. "
300-
"This option will be removed in Qiskit Experiments 0.6.",
301-
DeprecationWarning,
302-
stacklevel=2,
303-
)
304-
# Set the plotter drawer to `curve_drawer`. If `curve_drawer` is the right type, set it
305-
# directly. If not, wrap it in a compatibility drawer.
306-
if isinstance(fields["curve_drawer"], BaseDrawer):
307-
plotter = self.options.plotter
308-
plotter.drawer = fields.pop("curve_drawer")
309-
fields["plotter"] = plotter
310-
else:
311-
drawer = fields["curve_drawer"]
312-
compat_drawer = LegacyCurveCompatDrawer(drawer)
313-
plotter = self.options.plotter
314-
plotter.drawer = compat_drawer
315-
fields["plotter"] = plotter
316-
317274
for field in fields:
318275
if not hasattr(self.options, field):
319276
warnings.warn(
@@ -349,10 +306,7 @@ def _run_analysis(
349306
metadata = analysis.options.extra
350307
metadata["group"] = analysis.name
351308
analysis.set_options(
352-
plot=False,
353-
extra=metadata,
354-
return_fit_parameters=self.options.return_fit_parameters,
355-
return_data_points=self.options.return_data_points,
309+
plot=False, extra=metadata, return_fit_parameters=self.options.return_fit_parameters
356310
)
357311
results, _ = analysis._run_analysis(experiment_data)
358312
for res in results:

0 commit comments

Comments
 (0)