Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate warning box in docs #8600

Closed
wants to merge 54 commits into from
Closed
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
2dd1af7
deprecate_arguments and deprecate_function: add a deprecation note box
1ucian0 Aug 28, 2022
c77d833
Merge branch 'main' into deprecate_docstrings
1ucian0 Sep 4, 2022
82a1111
linting
1ucian0 Sep 4, 2022
8efdcf6
testing
1ucian0 Sep 4, 2022
51e7e72
testing docstrings
1ucian0 Sep 4, 2022
18bd25d
deprecate parameter in the parameter description
1ucian0 Sep 5, 2022
f24b3ea
Merge branch 'main' into deprecate_docstrings
1ucian0 Sep 6, 2022
4fc029c
deprecate_arguments
1ucian0 Sep 6, 2022
da68919
implementing all the deprecate_function
1ucian0 Sep 7, 2022
071fa5d
ups. testing
1ucian0 Sep 7, 2022
397e336
implement deprecate_arguments around
1ucian0 Sep 7, 2022
b873393
conflict and in-place
1ucian0 Sep 8, 2022
fbc2d74
ref to pep-0257
1ucian0 Sep 8, 2022
def73fc
deprecation message on top of Args
1ucian0 Sep 8, 2022
91c821d
avoiding being ate by Lev
1ucian0 Sep 8, 2022
c01fa65
Merge branch 'main' of github.com:Qiskit/qiskit-terra into deprecate_…
1ucian0 Sep 22, 2022
e5a22bc
docstring
1ucian0 Sep 22, 2022
ab7277a
docstring
1ucian0 Sep 22, 2022
e5feaf8
split tests
1ucian0 Sep 22, 2022
25c3a1e
Merge branch 'main' of github.com:Qiskit/qiskit-terra into deprecate_…
1ucian0 Sep 28, 2022
427a334
raise warning instead of exception
1ucian0 Sep 28, 2022
e67ce35
conflict solving
1ucian0 Oct 24, 2022
c9d4e38
lint
1ucian0 Oct 25, 2022
a7f0e0b
base_estimator
1ucian0 Oct 25, 2022
d48ef7c
Merge branch 'main' of github.com:Qiskit/qiskit-terra into deprecate_…
1ucian0 Oct 25, 2022
bdf623e
more merging conflicts
1ucian0 Oct 25, 2022
82b9cc2
turn into exception
1ucian0 Oct 25, 2022
b32cfc5
back to warning
1ucian0 Oct 25, 2022
033f49f
warnings.filterwarnings()
1ucian0 Oct 25, 2022
1f047e2
stacklevel=4
1ucian0 Oct 26, 2022
6a5b710
skip warning when a parameter is qobj
1ucian0 Oct 26, 2022
c7235cc
back to error
1ucian0 Oct 26, 2022
5baedd0
Merge branch 'main' of github.com:Qiskit/qiskit-terra into deprecate_…
1ucian0 Oct 26, 2022
25d1660
conf.py
1ucian0 Oct 26, 2022
39f28d2
adapt message
1ucian0 Oct 26, 2022
453cdfc
back to warning, to avoid braking integration tests
1ucian0 Oct 26, 2022
30175a1
Merge branch 'main' into deprecate_docstrings
1ucian0 Oct 31, 2022
624123b
Merge branch 'main' into deprecate_docstrings
1ucian0 Nov 12, 2022
3bb43f1
using regex
1ucian0 Nov 12, 2022
f4f54c8
fixing test
1ucian0 Nov 12, 2022
8f601ad
multi lines and empty
1ucian0 Nov 12, 2022
77c5c2f
type doc support
1ucian0 Nov 12, 2022
e73ae49
Merge branch 'main' into deprecate_docstrings
1ucian0 Nov 23, 2022
80f3def
Merge branch 'main' into deprecate_docstrings
1ucian0 Nov 30, 2022
172eef9
Merge branch 'main' into deprecate_docstrings
1ucian0 Jan 5, 2023
5503b05
Merge branch 'main' into deprecate_docstrings
1ucian0 Jan 9, 2023
44f3183
Merge branch 'main' into deprecate_docstrings
1ucian0 Jan 11, 2023
b98ebab
conflict solving
1ucian0 Jan 24, 2023
82aaba9
DeprecationWarning to PendingDeprecationWarning
1ucian0 Jan 24, 2023
97472d3
DeprecationWarning to PendingDeprecationWarning
1ucian0 Jan 25, 2023
3f005c8
Merge branch 'main' into deprecate_docstrings
1ucian0 Jan 25, 2023
5e8298f
DeprecationWarning to PendingDeprecationWarning
1ucian0 Jan 25, 2023
c94339c
Merge branch 'deprecate_docstrings' of github.com:1ucian0/qiskit-terr…
1ucian0 Jan 25, 2023
1fb35ec
DeprecationWarning to PendingDeprecationWarning
1ucian0 Jan 25, 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
3 changes: 2 additions & 1 deletion qiskit/algorithms/factorizers/shor.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ class Shor:

@deprecate_function(
"The Shor class is deprecated as of Qiskit Terra 0.22.0 "
"and will be removed no sooner than 3 months after the release date. "
"and will be removed no sooner than 3 months after the release date. ",
docstring_version="0.22.0",
)
def __init__(self, quantum_instance: Optional[Union[QuantumInstance, Backend]] = None) -> None:
"""
Expand Down
3 changes: 2 additions & 1 deletion qiskit/algorithms/linear_solvers/hhl.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ class HHL(LinearSolver):

@deprecate_function(
"The HHL class is deprecated as of Qiskit Terra 0.22.0 "
"and will be removed no sooner than 3 months after the release date. "
"and will be removed no sooner than 3 months after the release date. ",
docstring_version="0.22.0",
)
def __init__(
self,
Expand Down
6 changes: 4 additions & 2 deletions qiskit/algorithms/linear_solvers/linear_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ class LinearSolverResult(AlgorithmResult):

@deprecate_function(
"The LinearSolverResult class is deprecated as of Qiskit Terra 0.22.0 "
"and will be removed no sooner than 3 months after the release date. "
"and will be removed no sooner than 3 months after the release date. ",
docstring_version="0.22.0",
)
def __init__(self) -> None:
super().__init__()
Expand Down Expand Up @@ -102,7 +103,8 @@ class LinearSolver(ABC):

@deprecate_function(
"The LinearSolver class is deprecated as of Qiskit Terra 0.22.0 "
"and will be removed no sooner than 3 months after the release date. "
"and will be removed no sooner than 3 months after the release date. ",
docstring_version="0.22.0",
)
def __init__(self) -> None:
pass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class LinearSystemMatrix(BlueprintCircuit, ABC):

@deprecate_function(
"The LinearSystemMatrix class is deprecated as of Qiskit Terra 0.22.0 "
"and will be removed no sooner than 3 months after the release date. "
"and will be removed no sooner than 3 months after the release date. ",
docstring_version="0.22.0",
)
def __init__(
self,
Expand Down
3 changes: 2 additions & 1 deletion qiskit/algorithms/linear_solvers/matrices/numpy_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ class NumPyMatrix(LinearSystemMatrix):

@deprecate_function(
"The NumPyMatrix class is deprecated as of Qiskit Terra 0.22.0 "
"and will be removed no sooner than 3 months after the release date. "
"and will be removed no sooner than 3 months after the release date. ",
docstring_version="0.22.0",
)
def __init__(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ class TridiagonalToeplitz(LinearSystemMatrix):

@deprecate_function(
"The TridiagonalToeplitz class is deprecated as of Qiskit Terra 0.22.0 "
"and will be removed no sooner than 3 months after the release date. "
"and will be removed no sooner than 3 months after the release date. ",
docstring_version="0.22.0",
)
def __init__(
self,
Expand Down
3 changes: 2 additions & 1 deletion qiskit/algorithms/linear_solvers/numpy_linear_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ class NumPyLinearSolver(LinearSolver):

@deprecate_function(
"The NumPyLinearSolver class is deprecated as of Qiskit Terra 0.22.0 "
"and will be removed no sooner than 3 months after the release date. "
"and will be removed no sooner than 3 months after the release date. ",
docstring_version="0.22.0",
)
def __init__(self) -> None:
super().__init__()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ class AbsoluteAverage(LinearSystemObservable):

@deprecate_function(
"The AbsoluteAverage class is deprecated as of Qiskit Terra 0.22.0 "
"and will be removed no sooner than 3 months after the release date. "
"and will be removed no sooner than 3 months after the release date. ",
docstring_version="0.22.0",
)
def __init__(self) -> None:
super().__init__()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ class LinearSystemObservable(ABC):

@deprecate_function(
"The LinearSystemObservable class is deprecated as of Qiskit Terra 0.22.0 "
"and will be removed no sooner than 3 months after the release date. "
"and will be removed no sooner than 3 months after the release date. ",
docstring_version="0.22.0",
)
def __init__(self) -> None:
pass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ class MatrixFunctional(LinearSystemObservable):

@deprecate_function(
"The MatrixFunctional class is deprecated as of Qiskit Terra 0.22.0 "
"and will be removed no sooner than 3 months after the release date. "
"and will be removed no sooner than 3 months after the release date. ",
docstring_version="0.22.0",
)
def __init__(self, main_diag: float, off_diag: int) -> None:
"""
Expand Down
3 changes: 2 additions & 1 deletion qiskit/algorithms/optimizers/adam_amsgrad.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ def load_params(self, load_dir: str) -> None:
"objective_function": "fun",
"initial_point": "x0",
"gradient_function": "jac",
}
},
docstring_version="0.19.0",
)
# pylint: disable=arguments-differ
def minimize(
Expand Down
3 changes: 2 additions & 1 deletion qiskit/algorithms/optimizers/spsa.py
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,8 @@ def get_support_level(self):
"The SPSA.optimize method is deprecated as of Qiskit Terra 0.21.0 and will be removed no "
"sooner than 3 months after the release date. Instead, use SPSA.minimize as a replacement, "
"which supports the same arguments but follows the interface of scipy.optimize and returns "
"a complete result object containing additional information."
"a complete result object containing additional information.",
docstring_version="0.21.0",
)
def optimize(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ def circuit_result(self) -> Result:
@deprecate_function(
"""The 'PhaseEstimationResult.most_likely_phase' attribute
is deprecated as of 0.18.0 and will be removed no earlier than 3 months
after the release date. It has been renamed as the 'phase' attribute."""
after the release date. It has been renamed as the 'phase' attribute.""",
docstring_version="0.18.0",
)
def most_likely_phase(self) -> float:
r"""DEPRECATED - Return the most likely phase as a number in :math:`[0.0, 1.0)`.
Expand Down
26 changes: 17 additions & 9 deletions qiskit/circuit/quantumcircuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -716,10 +716,11 @@ def control(
@deprecate_function(
"The QuantumCircuit.combine() method is being deprecated. "
"Use the compose() method which is more flexible w.r.t "
"circuit register compatibility."
"circuit register compatibility.",
docstring_version="0.17.0",
)
def combine(self, rhs: "QuantumCircuit") -> "QuantumCircuit":
"""DEPRECATED - Returns rhs appended to self if self contains compatible registers.
"""Returns rhs appended to self if self contains compatible registers.

Two circuits are compatible if they contain the same registers
or if they contain different registers with unique names. The
Expand Down Expand Up @@ -768,7 +769,8 @@ def combine(self, rhs: "QuantumCircuit") -> "QuantumCircuit":
@deprecate_function(
"The QuantumCircuit.extend() method is being deprecated. Use the "
"compose() (potentially with the inplace=True argument) and tensor() "
"methods which are more flexible w.r.t circuit register compatibility."
"methods which are more flexible w.r.t circuit register compatibility.",
docstring_version="0.17.0",
)
def extend(self, rhs: "QuantumCircuit") -> "QuantumCircuit":
"""DEPRECATED - Append QuantumCircuit to the RHS if it contains compatible registers.
Expand Down Expand Up @@ -3765,7 +3767,8 @@ def cu(
"0.16.0. It will be removed no earlier than 3 months "
"after the release date. You should use the "
"QuantumCircuit.p method instead, which acts "
"identically."
"identically.",
docstring_version="0.16.0",
)
def u1(self, theta: ParameterValueType, qubit: QubitSpecifier) -> InstructionSet:
r"""Apply :class:`~qiskit.circuit.library.U1Gate`.
Expand All @@ -3788,7 +3791,8 @@ def u1(self, theta: ParameterValueType, qubit: QubitSpecifier) -> InstructionSet
"0.16.0. It will be removed no earlier than 3 months "
"after the release date. You should use the "
"QuantumCircuit.cp method instead, which acts "
"identically."
"identically.",
docstring_version="0.16.0",
)
def cu1(
self,
Expand Down Expand Up @@ -3825,7 +3829,8 @@ def cu1(
"0.16.0. It will be removed no earlier than 3 months "
"after the release date. You should use the "
"QuantumCircuit.mcp method instead, which acts "
"identically."
"identically.",
docstring_version="0.16.0",
)
def mcu1(
self,
Expand Down Expand Up @@ -3857,7 +3862,8 @@ def mcu1(
"qubit gate QuantumCircuit.u instead: u2(φ,λ) = "
"u(π/2, φ, λ). Alternatively, you can decompose it in"
"terms of QuantumCircuit.p and QuantumCircuit.sx: "
"u2(φ,λ) = p(π/2+φ) sx p(λ-π/2) (1 pulse on hardware)."
"u2(φ,λ) = p(π/2+φ) sx p(λ-π/2) (1 pulse on hardware).",
docstring_version="0.16.0",
)
def u2(
self, phi: ParameterValueType, lam: ParameterValueType, qubit: QubitSpecifier
Expand All @@ -3883,7 +3889,8 @@ def u2(
"removed no earlier than 3 months after the release date. You should use "
"QuantumCircuit.u instead, which acts identically. Alternatively, you can "
"decompose u3 in terms of QuantumCircuit.p and QuantumCircuit.sx: "
"u3(ϴ,φ,λ) = p(φ+π) sx p(ϴ+π) sx p(λ) (2 pulses on hardware)."
"u3(ϴ,φ,λ) = p(φ+π) sx p(ϴ+π) sx p(λ) (2 pulses on hardware).",
docstring_version="0.16.0",
)
def u3(
self,
Expand Down Expand Up @@ -3913,7 +3920,8 @@ def u3(
"The QuantumCircuit.cu3 method is deprecated as of 0.16.0. It will be "
"removed no earlier than 3 months after the release date. You should "
"use the QuantumCircuit.cu method instead, where "
"cu3(ϴ,φ,λ) = cu(ϴ,φ,λ,0)."
"cu3(ϴ,φ,λ) = cu(ϴ,φ,λ,0).",
docstring_version="0.16.0",
)
def cu3(
self,
Expand Down
9 changes: 6 additions & 3 deletions qiskit/dagcircuit/dagcircuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ def __init__(self):

@_optionals.HAS_NETWORKX.require_in_call
@deprecate_function(
"The to_networkx() method is deprecated and will be removed in a future release."
"The to_networkx() method is deprecated and will be removed in a future release.",
docstring_version="0.21.0",
)
def to_networkx(self):
"""Returns a copy of the DAGCircuit in networkx format."""
Expand All @@ -114,7 +115,8 @@ def to_networkx(self):
@classmethod
@_optionals.HAS_NETWORKX.require_in_call
@deprecate_function(
"The from_networkx() method is deprecated and will be removed in a future release."
"The from_networkx() method is deprecated and will be removed in a future release.",
docstring_version="0.21.0",
)
def from_networkx(cls, graph):
"""Take a networkx MultiDigraph and create a new DAGCircuit.
Expand Down Expand Up @@ -503,7 +505,8 @@ def _add_op_node(self, op, qargs, cargs):
"""The DAGCircuit._copy_circuit_metadata method is deprecated as of 0.20.0. It will be removed
no earlier than 3 months after the release date. You should use the DAGCircuit.copy_empty_like
method instead, which acts identically.
"""
""",
docstring_version="0.20.0",
)
def _copy_circuit_metadata(self):
"""DEPRECATED"""
Expand Down
14 changes: 10 additions & 4 deletions qiskit/primitives/base_estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,16 +219,18 @@ def __new__(

@deprecate_function(
"The BaseEstimator.__enter__ method is deprecated as of Qiskit Terra 0.22.0 "
"and will be removed no sooner than 3 months after the releasedate. "
"and will be removed no sooner than 3 months after the release date. "
"BaseEstimator should be initialized directly.",
docstring_version="0.22.0",
)
def __enter__(self):
return self

@deprecate_function(
"The BaseEstimator.__exit__ method is deprecated as of Qiskit Terra 0.22.0 "
"and will be removed no sooner than 3 months after the releasedate. "
"and will be removed no sooner than 3 months after the release date. "
"BaseEstimator should be initialized directly.",
docstring_version="0.22.0",
)
def __exit__(self, *exc_info):
self.close()
Expand Down Expand Up @@ -283,10 +285,14 @@ def set_run_options(self, **fields) -> BaseEstimator:

@deprecate_function(
"The BaseSampler.__call__ method is deprecated as of Qiskit Terra 0.22.0 "
"and will be removed no sooner than 3 months after the releasedate. "
"and will be removed no sooner than 3 months after the release date. "
"Use run method instead.",
docstring_version="0.22.0",
)
@deprecate_arguments(
{"circuit_indices": "circuits", "observable_indices": "observables"},
docstring_version="0.21.0",
)
@deprecate_arguments({"circuit_indices": "circuits", "observable_indices": "observables"})
def __call__(
self,
circuits: Sequence[int | QuantumCircuit],
Expand Down
8 changes: 4 additions & 4 deletions qiskit/primitives/base_sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,15 @@ def __new__(

@deprecate_function(
"The BaseSampler.__enter__ method is deprecated as of Qiskit Terra 0.22.0 "
"and will be removed no sooner than 3 months after the releasedate. "
"and will be removed no sooner than 3 months after the release date. "
"BaseSampler should be initialized directly.",
)
def __enter__(self):
return self

@deprecate_function(
"The BaseSampler.__exit__ method is deprecated as of Qiskit Terra 0.22.0 "
"and will be removed no sooner than 3 months after the releasedate. "
"and will be removed no sooner than 3 months after the release date. "
"BaseSampler should be initialized directly.",
)
def __exit__(self, *exc_info):
Expand Down Expand Up @@ -234,10 +234,10 @@ def set_run_options(self, **fields) -> BaseSampler:

@deprecate_function(
"The BaseSampler.__call__ method is deprecated as of Qiskit Terra 0.22.0 "
"and will be removed no sooner than 3 months after the releasedate. "
"and will be removed no sooner than 3 months after the release date. "
"Use run method instead.",
)
@deprecate_arguments({"circuit_indices": "circuits"})
@deprecate_arguments({"circuit_indices": "circuits"}, docstring_version="0.21.0")
def __call__(
self,
circuits: Sequence[int | QuantumCircuit],
Expand Down
2 changes: 1 addition & 1 deletion qiskit/qpy/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
VERSION_PATTERN_REGEX = re.compile(VERSION_PATTERN, re.VERBOSE | re.IGNORECASE)


@deprecate_arguments({"circuits": "programs"})
@deprecate_arguments({"circuits": "programs"}, docstring_version="0.21.0")
def dump(
programs: Union[List[QPY_SUPPORTED_TYPES], QPY_SUPPORTED_TYPES],
file_obj: BinaryIO,
Expand Down
16 changes: 9 additions & 7 deletions qiskit/scheduler/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
from qiskit.utils.deprecation import deprecate_function
from qiskit.pulse import macros, utils

format_meas_map = deprecate_function('"format_meas_map" has been moved to "qiskit.pulse.utils"')(
utils.format_meas_map
)
format_meas_map = deprecate_function(
'"format_meas_map" has been moved to "qiskit.pulse.utils"', docstring_version="0.15.0"
)(utils.format_meas_map)

measure = deprecate_function('"measure" has been moved to "qiskit.pulse.macros"')(macros.measure)
measure = deprecate_function(
'"measure" has been moved to "qiskit.pulse.macros"', docstring_version="0.15.0"
)(macros.measure)

measure_all = deprecate_function('"measure_all" has been moved to "qiskit.pulse.macros"')(
macros.measure_all
)
measure_all = deprecate_function(
'"measure_all" has been moved to "qiskit.pulse.macros"', docstring_version="0.15.0"
)(macros.measure_all)
2 changes: 1 addition & 1 deletion qiskit/transpiler/passes/basis/decompose.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
class Decompose(TransformationPass):
"""Expand a gate in a circuit using its decomposition rules."""

@deprecate_arguments({"gate": "gates_to_decompose"})
@deprecate_arguments({"gate": "gates_to_decompose"}, docstring_version="0.19.0")
def __init__(
self,
gate: Optional[Type[Gate]] = None,
Expand Down
Loading