Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
16cbe27
put 0.3.1 notes back in
coruscating Apr 19, 2023
45392e0
remove deprecations
coruscating Apr 19, 2023
60603e1
update deprecations and tests
coruscating Apr 19, 2023
14cb16c
Merge remote-tracking branch 'upstream/main' into 0.5-deprecations
coruscating Apr 19, 2023
8342781
remove custom deprecation functions
coruscating May 19, 2023
ae2bf9b
remove deprecated elements
coruscating May 19, 2023
6f82be1
Merge branch 'main' into 0.5-deprecations
coruscating May 19, 2023
aaf458c
replace block_for_results
coruscating May 19, 2023
b52fcbb
update contributing guide and remove qubit
coruscating May 20, 2023
25cbebf
change active deprecations to new syntax
coruscating May 22, 2023
4abdaa4
curve fit and tomography deprecations
coruscating May 22, 2023
ac103ae
more deprecations and fix tests
coruscating May 22, 2023
615f30c
update tests
coruscating May 22, 2023
e7e7e13
Merge branch 'main' into 0.5-deprecations
coruscating May 22, 2023
ca75c67
fix docs
coruscating May 22, 2023
2e4cdea
fix hamiltonian test
coruscating May 22, 2023
e3ad349
Merge branch '0.5-deprecations' of github.com:coruscating/qiskit-expe…
coruscating May 22, 2023
5748f62
fix docs and tests
coruscating May 23, 2023
14d4648
fix docs and tests
coruscating May 23, 2023
6e497f4
update docs
coruscating May 23, 2023
18eff9c
unify `physical_qubits` format to tuples in docs
coruscating May 25, 2023
bbfe5c9
Merge remote-tracking branch 'upstream/main' into 0.5-deprecations
coruscating May 25, 2023
ade1c63
Fix typo
coruscating May 25, 2023
f4ca678
Merge remote-tracking branch 'upstream/main' into 0.5-deprecations
coruscating Jun 5, 2023
3f48fd6
Remove old terra compatibility code
coruscating Jun 5, 2023
28288ea
lint
coruscating Jun 5, 2023
ac1ecd4
merge main
coruscating Jun 19, 2023
08c1b58
remove unneeded message
coruscating Jun 19, 2023
88c2544
Merge branch 'main' into 0.5-deprecations
coruscating Jun 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 10 additions & 19 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -354,35 +354,26 @@ minor releases and not on patch releases.

#### Adding deprecation warnings

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

```python

from qiskit_experiments.warnings import deprecated_function
from qiskit.utils.deprecation import deprecate_func

@deprecated_function(last_version="0.3", msg="Use new_function instead.")
@deprecate_func(
since="0.5",
additional_msg="Use ``new_function`` instead.",
removal_timeline="after 0.7",
package_name="qiskit-experiments",
)
def old_function(*args, **kwargs):
pass

def new_function(*args, **kwargs):
pass
```

To deprecate a class:

```python
from qiskit_experiments.warnings import deprecated_class

@deprecated_class(last_version="0.3", new_cls=NewCls)
class OldClass:
pass
class NewClass:
pass
```

This will inform the user which version of Qiskit Experiments will remove the deprecated
class or function.

### Development cycle

The development cycle for Qiskit Experiments is all handled in the open using project
Expand Down
6 changes: 3 additions & 3 deletions docs/manuals/characterization/t2hahn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ computed for other qubits.

.. jupyter-execute::

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

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

# Create a T2Hahn experiment with 1 echo. Print the first circuit as an example
exp2_1echoes = T2Hahn([qubit2], delays3, num_echoes=num_echoes)
exp2_1echoes = T2Hahn((qubit2,), delays3, num_echoes=num_echoes)
exp2_1echoes.analysis.set_options(p0={"amp": 0.5, "tau": estimated_t2hahn2, "base": 0.5})
print("The first circuit of hahn echo experiment with 1 echo:")
print(exp2_1echoes.circuits()[0])
Expand Down
6 changes: 3 additions & 3 deletions docs/manuals/measurement/restless_measurements.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ they use always starts with the qubits in the ground state.

# Define the experiment
qubit = 2
cal_drag = RoughDragCal(qubit, cals, schedule_name='sx', backend=backend)
cal_drag = RoughDragCal((qubit,), cals, schedule_name='sx', backend=backend)

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

cal_drag = RoughDragCal(qubit, cals, schedule_name='sx', backend=backend)
cal_drag = RoughDragCal((qubit,), cals, schedule_name='sx', backend=backend)
cal_drag.analysis.set_options(data_processor=standard_processor)

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

dt = BackendData(backend).dt
inst_map = backend.instruction_schedule_map
meas_length = inst_map.get("measure", (qubit, )).duration * dt
meas_length = inst_map.get("measure", (qubit,)).duration * dt

# Compute the average duration of all circuits
# Remove measurement instructions
Expand Down
2 changes: 1 addition & 1 deletion docs/manuals/verification/randomized_benchmarking.rst
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ The EPGs of two-qubit RB are analyzed with the corrected EPC if available.
# Run a 1-qubit RB experiment on qubits 1, 2 to determine the error-per-gate of 1-qubit gates
single_exps = BatchExperiment(
[
StandardRB([qubit], lengths_1_qubit, num_samples=num_samples, seed=seed)
StandardRB((qubit,), lengths_1_qubit, num_samples=num_samples, seed=seed)
for qubit in qubits
],
flatten_results=True,
Expand Down
2 changes: 1 addition & 1 deletion docs/manuals/verification/state_tomography.rst
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ For example if we want to perform 1-qubit QST on several qubits at once:
for i in range(num_qubits)]

subexps = [
StateTomography(gate, physical_qubits=[i])
StateTomography(gate, physical_qubits=(i,))
for i, gate in enumerate(gates)
]
parexp = ParallelExperiment(subexps)
Expand Down
8 changes: 4 additions & 4 deletions docs/tutorials/calibrations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ Instantiate the experiment and draw the first circuit in the sweep:

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

.. jupyter-execute::
Expand Down Expand Up @@ -391,7 +391,7 @@ over/under rotations is the highest.

.. jupyter-execute::

overamp_exp = FineXAmplitude(qubit, backend=backend)
overamp_exp = FineXAmplitude((qubit,), backend=backend)
overamp_exp.set_transpile_options(inst_map=inst_map)
overamp_exp.circuits()[4].draw(output='mpl')

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

# do the experiment
underamp_exp = FineXAmplitude(qubit, backend=backend)
underamp_exp = FineXAmplitude((qubit,), backend=backend)
underamp_exp.set_transpile_options(inst_map=inst_map)

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

from qiskit_experiments.library import FineSXAmplitudeCal

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

Let's run the calibration experiment:
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/data_processor.rst
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ The code below sets up the Rabi experiment.
backend = SingleTransmonTestBackend(seed=100)

exp = Rabi(
qubit=0,
physical_qubits=(0,),
backend=backend,
schedule=sched,
amplitudes=np.linspace(-0.1, 0.1, 21)
Expand Down
5 changes: 0 additions & 5 deletions qiskit_experiments/curve_analysis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@
fit_function.sqrt_lorentzian
fit_function.sin
fit_function.sin_decay
fit_function.bloch_oscillation_x
fit_function.bloch_oscillation_y
fit_function.bloch_oscillation_z

Initial Guess Estimators
========================
Expand Down Expand Up @@ -129,8 +126,6 @@
SeriesDef,
)
from .curve_fit import (
curve_fit,
multi_curve_fit,
process_curve_data,
process_multi_curve_data,
)
Expand Down
11 changes: 7 additions & 4 deletions qiskit_experiments/curve_analysis/base_curve_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import lmfit

from qiskit.utils.deprecation import deprecate_func

from qiskit_experiments.data_processing import DataProcessor
from qiskit_experiments.data_processing.processor_library import get_processor
from qiskit_experiments.framework import (
Expand All @@ -35,7 +37,6 @@
LegacyCurveCompatDrawer,
MplDrawer,
)
from qiskit_experiments.warnings import deprecated_function

from .curve_data import CurveData, CurveFitResult, ParameterRepr

Expand Down Expand Up @@ -131,9 +132,11 @@ def plotter(self) -> BasePlotter:
return self._options.plotter

@property
@deprecated_function(
last_version="0.6",
msg="Replaced by `plotter` from the new visualization submodule.",
@deprecate_func(
since="0.5",
additional_msg="Use `plotter` from the new visualization module.",
removal_timeline="after 0.6",
package_name="qiskit-experiments",
)
def drawer(self) -> BaseDrawer:
"""A short-cut for curve drawer instance, if set. ``None`` otherwise."""
Expand Down
11 changes: 7 additions & 4 deletions qiskit_experiments/curve_analysis/composite_curve_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import numpy as np
from uncertainties import unumpy as unp

from qiskit.utils.deprecation import deprecate_func

from qiskit_experiments.framework import (
AnalysisResultData,
BaseAnalysis,
Expand All @@ -34,7 +36,6 @@
LegacyCurveCompatDrawer,
MplDrawer,
)
from qiskit_experiments.warnings import deprecated_function

from .base_curve_analysis import PARAMS_ENTRY_PREFIX, BaseCurveAnalysis
from .curve_data import CurveFitResult
Expand Down Expand Up @@ -142,9 +143,11 @@ def plotter(self) -> BasePlotter:
return self._options.plotter

@property
@deprecated_function(
last_version="0.6",
msg="Replaced by `plotter` from the new visualization submodule.",
@deprecate_func(
since="0.5",
additional_msg="Use `plotter` from the new visualization module instead.",
removal_timeline="after 0.6",
package_name="qiskit-experiments",
)
def drawer(self) -> BaseDrawer:
"""A short-cut for curve drawer instance, if set. ``None`` otherwise."""
Expand Down
32 changes: 22 additions & 10 deletions qiskit_experiments/curve_analysis/curve_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@
import numpy as np
import uncertainties
from uncertainties.unumpy import uarray

from qiskit.utils.deprecation import deprecate_func

from qiskit_experiments.exceptions import AnalysisError
from qiskit_experiments.warnings import deprecated_function, deprecated_class


@deprecated_class("0.5", msg="SeriesDef is now replaced with LMFIT Model.")
@dataclasses.dataclass(frozen=True)
class SeriesDef:
"""A dataclass to describe the definition of the curve.
Expand Down Expand Up @@ -62,6 +63,16 @@ class SeriesDef:
model_description: Optional[str] = None
signature: Tuple[str, ...] = dataclasses.field(init=False)

@deprecate_func(
since="0.5",
additional_msg="SeriesDef has been replaced by the LMFIT module.",
removal_timeline="after 0.6",
package_name="qiskit-experiments",
)
def __init__(self, *args, **kwargs):
self.args = args
self.kwargs = kwargs

def __post_init__(self):
"""Parse the fit function signature to extract the names of the variables.
Fit functions take arguments F(x, p0, p1, p2, ...) thus the first value should be excluded.
Expand Down Expand Up @@ -249,11 +260,6 @@ def correl(self):
setattr(self, "_correl", correl)
return correl

@deprecated_function("0.5", "Use '.ufloat_params' which returns a dictionary instead.")
def fitval(self, key: str) -> uncertainties.UFloat:
"""Deprecated. Return UFloat parameter specified by the key."""
return self.ufloat_params[key]

def __str__(self):
ret = "CurveFitResult:"
ret += f"\n - fitting method: {self.method}"
Expand Down Expand Up @@ -328,9 +334,6 @@ def __json_decode__(cls, value):
return cls(**value)


@deprecated_class(
"0.5", msg="Fit data is replaced with 'CurveFitResult' based on LMFIT minimizer result."
)
@dataclasses.dataclass(frozen=True)
class FitData:
"""A dataclass to store the outcome of the fitting.
Expand All @@ -353,6 +356,15 @@ class FitData:
x_data: np.ndarray
y_data: np.ndarray

@deprecate_func(
since="0.5",
additional_msg="Fit data is replaced with 'CurveFitResult' based on LMFIT minimizer result.",
removal_timeline="after 0.6",
package_name="qiskit-experiments",
)
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

@property
def x_range(self) -> Tuple[float, float]:
"""Range of x values."""
Expand Down
Loading