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

Add since argument to deprecation functions #9616

Merged
merged 5 commits into from
Feb 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions qiskit/algorithms/amplitude_amplifiers/grover.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ def __init__(
"This property will be deprecated in a future release and subsequently "
"removed after that.",
category=PendingDeprecationWarning,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not that it matters too much but all the algorithms were marked pending in 0.22. With the PR to change algorithms over from pending to fully deprecated, for the next release, I imagine this since would change as well (to 0.24.0) to reflect the change to the category. and be a base for that, rather than the version where things commenced with pending.

Copy link
Collaborator Author

@Eric-Arellano Eric-Arellano Feb 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, as in, I can set these pending ones to be since="0.24.0"? I like that!

It's better than my plan before to have the documentation plugin render the version as 0.23.0_pending. I think 0.24.0 is more clear than 0.23.0_pending. And it avoids the deprecation author from needing to change since=0.23.0 to since=0.24.0 once they switch from pending to deprecated.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm referring to #9532 of course. That will change things to deprecated such that its deprecated since 0.24.0. No docs should be published off any of this in the interim - so as long as the deprecated PR makes it in - have no reason to believe it won't though - things would be fine. It does make the change a kind of half-way house though - PendingDeprecation but with the version that the Deprecation is intended to commence at!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. This makes me realize these semantics are better for pending deprecations:

If the deprecation is pending, set the version to when the deprecation will officially start.

That makes the .. deprecated :: directive have a more sensible version, e.g. we will show 0.24.0 rather than 0.23.0_pending. And less work for authors when switching Pending because the since version won't need to change at all.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that this is the best strategy - it could just be the responsibility of #9532 to update the version once it's certain. The deprecations of these algorithms were already pushed back one minor version, and while there's no particular indication it'll change again, I think we probably ought to build the policy around "since" referring to the warning that's actually being emitted, not one that we expect to emit in the future.

since="0.23.0",
)
def quantum_instance(self) -> Optional[QuantumInstance]:
r"""Pending deprecation\; Get the quantum instance.
Expand All @@ -211,6 +212,7 @@ def quantum_instance(self) -> Optional[QuantumInstance]:
"This property will be deprecated in a future release and subsequently "
"removed after that.",
category=PendingDeprecationWarning,
since="0.23.0",
)
def quantum_instance(self, quantum_instance: Union[QuantumInstance, Backend]) -> None:
r"""Pending deprecation\; Set quantum instance.
Expand Down
2 changes: 2 additions & 0 deletions qiskit/algorithms/amplitude_estimators/ae.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def sampler(self, sampler: BaseSampler) -> None:
"This property will be deprecated in a future release and subsequently "
"removed after that.",
category=PendingDeprecationWarning,
since="0.23.0",
)
def quantum_instance(self) -> QuantumInstance | None:
"""Pending deprecation; Get the quantum instance.
Expand All @@ -144,6 +145,7 @@ def quantum_instance(self) -> QuantumInstance | None:
"This property will be deprecated in a future release and subsequently "
"removed after that.",
category=PendingDeprecationWarning,
since="0.23.0",
)
def quantum_instance(self, quantum_instance: QuantumInstance | Backend) -> None:
"""Pending deprecation; Set quantum instance.
Expand Down
2 changes: 2 additions & 0 deletions qiskit/algorithms/amplitude_estimators/fae.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ def sampler(self, sampler: BaseSampler) -> None:
"This property will be deprecated in a future release and subsequently "
"removed after that.",
category=PendingDeprecationWarning,
since="0.23.0",
)
def quantum_instance(self) -> QuantumInstance | None:
"""Pending deprecation; Get the quantum instance.
Expand All @@ -129,6 +130,7 @@ def quantum_instance(self) -> QuantumInstance | None:
"This property will be deprecated in a future release and subsequently "
"removed after that.",
category=PendingDeprecationWarning,
since="0.23.0",
)
def quantum_instance(self, quantum_instance: QuantumInstance | Backend) -> None:
"""Pending deprecation; Set quantum instance.
Expand Down
2 changes: 2 additions & 0 deletions qiskit/algorithms/amplitude_estimators/iae.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def sampler(self, sampler: BaseSampler) -> None:
"This property will be deprecated in a future release and subsequently "
"removed after that.",
category=PendingDeprecationWarning,
since="0.23.0",
)
def quantum_instance(self) -> QuantumInstance | None:
"""Pending deprecation; Get the quantum instance.
Expand All @@ -152,6 +153,7 @@ def quantum_instance(self) -> QuantumInstance | None:
"This property will be deprecated in a future release and subsequently "
"removed after that.",
category=PendingDeprecationWarning,
since="0.23.0",
)
def quantum_instance(self, quantum_instance: QuantumInstance | Backend) -> None:
"""Pending deprecation; Set quantum instance.
Expand Down
2 changes: 2 additions & 0 deletions qiskit/algorithms/amplitude_estimators/mlae.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ def sampler(self, sampler: BaseSampler) -> None:
"This property will be deprecated in a future release and subsequently "
"removed after that.",
category=PendingDeprecationWarning,
since="0.23.0",
)
def quantum_instance(self) -> QuantumInstance | None:
"""Pending deprecation; Get the quantum instance.
Expand All @@ -156,6 +157,7 @@ def quantum_instance(self) -> QuantumInstance | None:
"This property will be deprecated in a future release and subsequently "
"removed after that.",
category=PendingDeprecationWarning,
since="0.23.0",
)
def quantum_instance(self, quantum_instance: QuantumInstance | Backend) -> None:
"""Pending deprecation; Set quantum instance.
Expand Down
1 change: 1 addition & 0 deletions qiskit/algorithms/aux_ops_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"This function will be deprecated in a future release and subsequently "
"removed after that.",
category=PendingDeprecationWarning,
since="0.23.0",
)
def eval_observables(
quantum_instance: Union[QuantumInstance, Backend],
Expand Down
2 changes: 2 additions & 0 deletions qiskit/algorithms/eigen_solvers/eigen_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class Eigensolver(ABC):
"This interface will be deprecated in a future release and subsequently "
"removed after that.",
category=PendingDeprecationWarning,
since="0.23.0",
)
def __init__(self) -> None:
pass
Expand Down Expand Up @@ -94,6 +95,7 @@ class EigensolverResult(AlgorithmResult):
"This class will be deprecated in a future release and subsequently "
"removed after that.",
category=PendingDeprecationWarning,
since="0.23.0",
)
def __init__(self) -> None:
super().__init__()
Expand Down
1 change: 1 addition & 0 deletions qiskit/algorithms/eigen_solvers/numpy_eigen_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class NumPyEigensolver(Eigensolver):
"This class will be deprecated in a future release and subsequently "
"removed after that.",
category=PendingDeprecationWarning,
since="0.23.0",
)
def __init__(
self,
Expand Down
2 changes: 2 additions & 0 deletions qiskit/algorithms/eigen_solvers/vqd.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class VQD(VariationalAlgorithm, Eigensolver):
"This class will be deprecated in a future release and subsequently "
"removed after that.",
category=PendingDeprecationWarning,
since="0.23.0",
)
def __init__(
self,
Expand Down Expand Up @@ -772,6 +773,7 @@ class VQDResult(VariationalResult, EigensolverResult):
"This class will be deprecated in a future release and subsequently "
"removed after that.",
category=PendingDeprecationWarning,
since="0.23.0",
)
def __init__(self) -> None:
super().__init__()
Expand Down
1 change: 1 addition & 0 deletions qiskit/algorithms/evolvers/evolution_problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class EvolutionProblem:
"This class will be deprecated in a future release and subsequently "
"removed after that.",
category=PendingDeprecationWarning,
since="0.23.0",
)
def __init__(
self,
Expand Down
1 change: 1 addition & 0 deletions qiskit/algorithms/evolvers/evolution_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class EvolutionResult(AlgorithmResult):
"This class will be deprecated in a future release and subsequently "
"removed after that.",
category=PendingDeprecationWarning,
since="0.23.0",
)
def __init__(
self,
Expand Down
1 change: 1 addition & 0 deletions qiskit/algorithms/evolvers/imaginary_evolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class ImaginaryEvolver(ABC):
"This interface will be deprecated in a future release and subsequently "
"removed after that.",
category=PendingDeprecationWarning,
since="0.23.0",
)
def __init__(self) -> None:
pass
Expand Down
1 change: 1 addition & 0 deletions qiskit/algorithms/evolvers/real_evolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class RealEvolver(ABC):
"This interface will be deprecated in a future release and subsequently "
"removed after that.",
category=PendingDeprecationWarning,
since="0.23.0",
)
def __init__(self) -> None:
pass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class TrotterQRTE(RealEvolver):
"This class will be deprecated in a future release and subsequently "
"removed after that.",
category=PendingDeprecationWarning,
since="0.23.0",
)
def __init__(
self,
Expand Down
3 changes: 2 additions & 1 deletion qiskit/algorithms/factorizers/shor.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ class Shor:
"""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.
It is replaced by the tutorial at https://qiskit.org/textbook/ch-algorithms/shor.html
"""
""",
since="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 @@ -110,7 +110,8 @@ class HHL(LinearSolver):
"""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.
It is replaced by the tutorial at https://qiskit.org/textbook/ch-applications/hhl_tutorial.html"
"""
""",
since="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.",
since="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.",
since="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.",
since="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 @@ -48,7 +48,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.",
since="0.22.0",
)
def __init__(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,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.",
since="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 @@ -53,7 +53,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. ",
since="0.22.0",
)
def __init__(self) -> None:
super().__init__()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,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.",
since="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.",
since="0.22.0",
)
def __init__(self) -> None:
pass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,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.",
since="0.22.0",
)
def __init__(self, main_diag: float, off_diag: int) -> None:
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class MinimumEigensolver(ABC):
"This interface will be deprecated in a future release and subsequently "
"removed after that.",
category=PendingDeprecationWarning,
since="0.23.0",
)
def __init__(self) -> None:
pass
Expand Down Expand Up @@ -98,6 +99,7 @@ class MinimumEigensolverResult(AlgorithmResult):
"This class will be deprecated in a future release and subsequently "
"removed after that.",
category=PendingDeprecationWarning,
since="0.23.0",
)
def __init__(self) -> None:
super().__init__()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class NumPyMinimumEigensolver(MinimumEigensolver):
"This class will be deprecated in a future release and subsequently "
"removed after that.",
category=PendingDeprecationWarning,
since="0.23.0",
)
def __init__(
self,
Expand Down
1 change: 1 addition & 0 deletions qiskit/algorithms/minimum_eigen_solvers/qaoa.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class QAOA(VQE):
"This class will be deprecated in a future release and subsequently "
"removed after that.",
category=PendingDeprecationWarning,
since="0.23.0",
)
def __init__(
self,
Expand Down
2 changes: 2 additions & 0 deletions qiskit/algorithms/minimum_eigen_solvers/vqe.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ def my_minimizer(fun, x0, jac=None, bounds=None) -> OptimizerResult:
"This class will be deprecated in a future release and subsequently "
"removed after that.",
category=PendingDeprecationWarning,
since="0.23.0",
)
def __init__(
self,
Expand Down Expand Up @@ -672,6 +673,7 @@ class VQEResult(VariationalResult, MinimumEigensolverResult):
"This class will be deprecated in a future release and subsequently "
"removed after that.",
category=PendingDeprecationWarning,
since="0.23.0",
)
def __init__(self) -> None:
with warnings.catch_warnings():
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",
}
},
since="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.",
since="0.21.0",
)
def optimize(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ def circuit_result(self) -> Result:
@property
@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."""
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.""",
since="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
3 changes: 2 additions & 1 deletion qiskit/circuit/classicalregister.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ class ClassicalRegister(Register):
@deprecate_function(
"Register.qasm() is deprecated since Terra 0.23, as correct exporting to OpenQASM 2 is "
"the responsibility of a larger exporter; it cannot safely be done on an object-by-object "
"basis without context. No replacement will be provided, because the premise is wrong."
"basis without context. No replacement will be provided, because the premise is wrong.",
since="0.23.0",
)
def qasm(self):
"""Return OPENQASM string for this register."""
Expand Down
3 changes: 2 additions & 1 deletion qiskit/circuit/quantumregister.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ class QuantumRegister(Register):
@deprecate_function(
"Register.qasm() is deprecated since Terra 0.23, as correct exporting to OpenQASM 2 is "
"the responsibility of a larger exporter; it cannot safely be done on an object-by-object "
"basis without context. No replacement will be provided, because the premise is wrong."
"basis without context. No replacement will be provided, because the premise is wrong.",
since="0.23.0",
)
def qasm(self):
"""Return OPENQASM string for this register."""
Expand Down
3 changes: 2 additions & 1 deletion qiskit/dagcircuit/dagcircuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,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.
"""
""",
since="0.20.0",
)
def _copy_circuit_metadata(self):
"""DEPRECATED"""
Expand Down
Loading