Skip to content

Commit 1b38872

Browse files
authored
Remove 0.5 deprecations (#1186)
### Summary This PR removes objects scheduled for removal after the 0.5 release and switches deprecation wrappers to the new Terra wrappers introduced in 0.24. ### Details and comments - Note that deprecating dataclasses will cause the docs to render their fields as `*args` and `**kwargs` at present. This is being tracked in Qiskit/qiskit#10144. - Tests using `block_for_results()` have also switched to `assertExperimentDone()` where possible. - Adds 0.3.1 release notes back in release notes for 0.4.
1 parent fd21740 commit 1b38872

File tree

89 files changed

+321
-1340
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+321
-1340
lines changed

CONTRIBUTING.md

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -354,35 +354,26 @@ minor releases and not on patch releases.
354354

355355
#### Adding deprecation warnings
356356

357-
We have a deprecation decorator for showing deprecation warnings. To
358-
deprecate a function, for example:
357+
We use the deprecation wrappers in [Qiskit
358+
Utilities](https://qiskit.org/documentation/apidoc/utils.html) to add warnings:
359359

360360
```python
361361

362-
from qiskit_experiments.warnings import deprecated_function
362+
from qiskit.utils.deprecation import deprecate_func
363363

364-
@deprecated_function(last_version="0.3", msg="Use new_function instead.")
364+
@deprecate_func(
365+
since="0.5",
366+
additional_msg="Use ``new_function`` instead.",
367+
removal_timeline="after 0.7",
368+
package_name="qiskit-experiments",
369+
)
365370
def old_function(*args, **kwargs):
366371
pass
372+
367373
def new_function(*args, **kwargs):
368374
pass
369375
```
370376

371-
To deprecate a class:
372-
373-
```python
374-
from qiskit_experiments.warnings import deprecated_class
375-
376-
@deprecated_class(last_version="0.3", new_cls=NewCls)
377-
class OldClass:
378-
pass
379-
class NewClass:
380-
pass
381-
```
382-
383-
This will inform the user which version of Qiskit Experiments will remove the deprecated
384-
class or function.
385-
386377
### Development cycle
387378

388379
The development cycle for Qiskit Experiments is all handled in the open using project

docs/manuals/characterization/t2hahn.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ computed for other qubits.
125125

126126
.. jupyter-execute::
127127

128-
exp_with_p0 = T2Hahn(physical_qubits=[qubit], delays=delays, num_echoes=number_of_echoes)
128+
exp_with_p0 = T2Hahn(physical_qubits=(qubit,), delays=delays, num_echoes=number_of_echoes)
129129
exp_with_p0.analysis.set_options(p0={"amp": 0.5, "tau": estimated_t2hahn, "base": 0.5})
130130
expdata_with_p0 = exp_with_p0.run(backend=backend, shots=2000, seed_simulator=101)
131131
expdata_with_p0.block_for_results()
@@ -190,13 +190,13 @@ total delay time.
190190
estimated_t2hahn2 = 30 * conversion_factor
191191

192192
# Create a T2Hahn experiment with 0 echoes
193-
exp2_0echoes = T2Hahn([qubit2], delays2, num_echoes=0)
193+
exp2_0echoes = T2Hahn((qubit2,), delays2, num_echoes=0)
194194
exp2_0echoes.analysis.set_options(p0={"amp": 0.5, "tau": estimated_t2hahn2, "base": 0.5})
195195
print("The first circuit of hahn echo experiment with 0 echoes:")
196196
print(exp2_0echoes.circuits()[0])
197197

198198
# Create a T2Hahn experiment with 1 echo. Print the first circuit as an example
199-
exp2_1echoes = T2Hahn([qubit2], delays3, num_echoes=num_echoes)
199+
exp2_1echoes = T2Hahn((qubit2,), delays3, num_echoes=num_echoes)
200200
exp2_1echoes.analysis.set_options(p0={"amp": 0.5, "tau": estimated_t2hahn2, "base": 0.5})
201201
print("The first circuit of hahn echo experiment with 1 echo:")
202202
print(exp2_1echoes.circuits()[0])

docs/manuals/measurement/restless_measurements.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ they use always starts with the qubits in the ground state.
7474

7575
# Define the experiment
7676
qubit = 2
77-
cal_drag = RoughDragCal(qubit, cals, schedule_name='sx', backend=backend)
77+
cal_drag = RoughDragCal((qubit,), cals, schedule_name='sx', backend=backend)
7878

7979
# Enable restless measurements by setting the run options and data processor
8080
cal_drag.enable_restless(rep_delay=1e-6)
@@ -111,7 +111,7 @@ the standard data processor by providing it to the analysis options and telling
111111
# define a standard data processor.
112112
standard_processor = DataProcessor("counts", [Probability("1")])
113113

114-
cal_drag = RoughDragCal(qubit, cals, schedule_name='sx', backend=backend)
114+
cal_drag = RoughDragCal((qubit,), cals, schedule_name='sx', backend=backend)
115115
cal_drag.analysis.set_options(data_processor=standard_processor)
116116

117117
# enable restless mode and set override_processor_by_restless to False.
@@ -162,7 +162,7 @@ using the code below.
162162

163163
dt = BackendData(backend).dt
164164
inst_map = backend.instruction_schedule_map
165-
meas_length = inst_map.get("measure", (qubit, )).duration * dt
165+
meas_length = inst_map.get("measure", (qubit,)).duration * dt
166166

167167
# Compute the average duration of all circuits
168168
# Remove measurement instructions

docs/manuals/verification/randomized_benchmarking.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ The EPGs of two-qubit RB are analyzed with the corrected EPC if available.
175175
# Run a 1-qubit RB experiment on qubits 1, 2 to determine the error-per-gate of 1-qubit gates
176176
single_exps = BatchExperiment(
177177
[
178-
StandardRB([qubit], lengths_1_qubit, num_samples=num_samples, seed=seed)
178+
StandardRB((qubit,), lengths_1_qubit, num_samples=num_samples, seed=seed)
179179
for qubit in qubits
180180
],
181181
flatten_results=True,

docs/manuals/verification/state_tomography.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ For example if we want to perform 1-qubit QST on several qubits at once:
168168
for i in range(num_qubits)]
169169

170170
subexps = [
171-
StateTomography(gate, physical_qubits=[i])
171+
StateTomography(gate, physical_qubits=(i,))
172172
for i, gate in enumerate(gates)
173173
]
174174
parexp = ParallelExperiment(subexps)

docs/tutorials/calibrations.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ Instantiate the experiment and draw the first circuit in the sweep:
166166

167167
freq01_estimate = backend.defaults().qubit_freq_est[qubit]
168168
frequencies = np.linspace(freq01_estimate-15e6, freq01_estimate+15e6, 51)
169-
spec = RoughFrequencyCal([qubit], cals, frequencies, backend=backend)
169+
spec = RoughFrequencyCal((qubit,), cals, frequencies, backend=backend)
170170
spec.set_experiment_options(amp=0.005)
171171

172172
.. jupyter-execute::
@@ -391,7 +391,7 @@ over/under rotations is the highest.
391391

392392
.. jupyter-execute::
393393

394-
overamp_exp = FineXAmplitude(qubit, backend=backend)
394+
overamp_exp = FineXAmplitude((qubit,), backend=backend)
395395
overamp_exp.set_transpile_options(inst_map=inst_map)
396396
overamp_exp.circuits()[4].draw(output='mpl')
397397

@@ -415,7 +415,7 @@ experiment detects this error. We will compare the results to the over-rotation
415415
inst_map.add("x", (qubit,), x_under)
416416

417417
# do the experiment
418-
underamp_exp = FineXAmplitude(qubit, backend=backend)
418+
underamp_exp = FineXAmplitude((qubit,), backend=backend)
419419
underamp_exp.set_transpile_options(inst_map=inst_map)
420420

421421
exp_data_under = underamp_exp.run(backend).block_for_results()
@@ -459,7 +459,7 @@ error which we want to correct.
459459

460460
from qiskit_experiments.library import FineSXAmplitudeCal
461461

462-
amp_cal = FineSXAmplitudeCal([qubit], cals, backend=backend, schedule_name="sx")
462+
amp_cal = FineSXAmplitudeCal((qubit,), cals, backend=backend, schedule_name="sx")
463463
amp_cal.circuits()[4].draw(output="mpl")
464464

465465
Let's run the calibration experiment:

docs/tutorials/data_processor.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ The code below sets up the Rabi experiment.
8888
backend = SingleTransmonTestBackend(seed=100)
8989

9090
exp = Rabi(
91-
qubit=0,
91+
physical_qubits=(0,),
9292
backend=backend,
9393
schedule=sched,
9494
amplitudes=np.linspace(-0.1, 0.1, 21)

qiskit_experiments/curve_analysis/__init__.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,6 @@
8181
fit_function.sqrt_lorentzian
8282
fit_function.sin
8383
fit_function.sin_decay
84-
fit_function.bloch_oscillation_x
85-
fit_function.bloch_oscillation_y
86-
fit_function.bloch_oscillation_z
8784
8885
Initial Guess Estimators
8986
========================
@@ -129,8 +126,6 @@
129126
SeriesDef,
130127
)
131128
from .curve_fit import (
132-
curve_fit,
133-
multi_curve_fit,
134129
process_curve_data,
135130
process_multi_curve_data,
136131
)

qiskit_experiments/curve_analysis/base_curve_analysis.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
import lmfit
2222

23+
from qiskit.utils.deprecation import deprecate_func
24+
2325
from qiskit_experiments.data_processing import DataProcessor
2426
from qiskit_experiments.data_processing.processor_library import get_processor
2527
from qiskit_experiments.framework import (
@@ -35,7 +37,6 @@
3537
LegacyCurveCompatDrawer,
3638
MplDrawer,
3739
)
38-
from qiskit_experiments.warnings import deprecated_function
3940

4041
from .curve_data import CurveData, CurveFitResult, ParameterRepr
4142

@@ -131,9 +132,11 @@ def plotter(self) -> BasePlotter:
131132
return self._options.plotter
132133

133134
@property
134-
@deprecated_function(
135-
last_version="0.6",
136-
msg="Replaced by `plotter` from the new visualization submodule.",
135+
@deprecate_func(
136+
since="0.5",
137+
additional_msg="Use `plotter` from the new visualization module.",
138+
removal_timeline="after 0.6",
139+
package_name="qiskit-experiments",
137140
)
138141
def drawer(self) -> BaseDrawer:
139142
"""A short-cut for curve drawer instance, if set. ``None`` otherwise."""

qiskit_experiments/curve_analysis/composite_curve_analysis.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import numpy as np
2222
from uncertainties import unumpy as unp
2323

24+
from qiskit.utils.deprecation import deprecate_func
25+
2426
from qiskit_experiments.framework import (
2527
AnalysisResultData,
2628
BaseAnalysis,
@@ -34,7 +36,6 @@
3436
LegacyCurveCompatDrawer,
3537
MplDrawer,
3638
)
37-
from qiskit_experiments.warnings import deprecated_function
3839

3940
from .base_curve_analysis import PARAMS_ENTRY_PREFIX, BaseCurveAnalysis
4041
from .curve_data import CurveFitResult
@@ -142,9 +143,11 @@ def plotter(self) -> BasePlotter:
142143
return self._options.plotter
143144

144145
@property
145-
@deprecated_function(
146-
last_version="0.6",
147-
msg="Replaced by `plotter` from the new visualization submodule.",
146+
@deprecate_func(
147+
since="0.5",
148+
additional_msg="Use `plotter` from the new visualization module instead.",
149+
removal_timeline="after 0.6",
150+
package_name="qiskit-experiments",
148151
)
149152
def drawer(self) -> BaseDrawer:
150153
"""A short-cut for curve drawer instance, if set. ``None`` otherwise."""

0 commit comments

Comments
 (0)