Skip to content

Commit

Permalink
default package_name='qiskit' for deprecate_func and `deprecate_a…
Browse files Browse the repository at this point in the history
…rgs` (#10877)

* changing the defailt to qiskit

* explict paramater with terra

* revert qiskit/scheduler/utils.py

* black

* change Aer

* Readjust deprecation message

---------

Co-authored-by: Julien Gacon <gaconju@gmail.com>
Co-authored-by: <57907331+ElePT@users.noreply.github.com>

* 0.45 and higher does not change

---------

Co-authored-by: Julien Gacon <gaconju@gmail.com>
  • Loading branch information
1ucian0 and Cryoris authored Nov 1, 2023
1 parent 05d958b commit 5a948c2
Show file tree
Hide file tree
Showing 122 changed files with 226 additions and 32 deletions.
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@
# Redirects
# ----------------------------------------------------------------------------------


def determine_api_redirects() -> dict[str, str]:
"""Set up API redirects for functions that we moved to module pages.
Expand All @@ -257,8 +258,7 @@ def determine_api_redirects() -> dict[str, str]:
obj_name, new_module_page_name = line.split(" ")
# E.g. `../apidoc/assembler.html#qiskit.assembler.assemble_circuits
new_url = (
"https://qiskit.org/documentation/apidoc/" +
f"{new_module_page_name}.html#{obj_name}"
"https://qiskit.org/documentation/apidoc/" + f"{new_module_page_name}.html#{obj_name}"
)
result[f"stubs/{obj_name}"] = new_url
return result
Expand Down
3 changes: 3 additions & 0 deletions qiskit/algorithms/amplitude_amplifiers/grover.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ class Grover(AmplitudeAmplifier):
"See https://qisk.it/algo_migration for a migration guide."
),
since="0.24.0",
package_name="qiskit-terra",
)
def __init__(
self,
Expand Down Expand Up @@ -198,6 +199,7 @@ def __init__(
@property
@deprecate_func(
since="0.24.0",
package_name="qiskit-terra",
is_property=True,
additional_msg="See https://qisk.it/algo_migration for a migration guide.",
)
Expand All @@ -212,6 +214,7 @@ def quantum_instance(self) -> QuantumInstance | None:
@quantum_instance.setter
@deprecate_func(
since="0.24.0",
package_name="qiskit-terra",
is_property=True,
additional_msg="See https://qisk.it/algo_migration for a migration guide.",
)
Expand Down
3 changes: 3 additions & 0 deletions qiskit/algorithms/amplitude_estimators/ae.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class AmplitudeEstimation(AmplitudeEstimator):
"migration guide."
),
since="0.24.0",
package_name="qiskit-terra",
)
def __init__(
self,
Expand Down Expand Up @@ -135,6 +136,7 @@ def sampler(self, sampler: BaseSampler) -> None:
@deprecate_func(
additional_msg="See https://qisk.it/algo_migration for a migration guide.",
since="0.24.0",
package_name="qiskit-terra",
is_property=True,
)
def quantum_instance(self) -> QuantumInstance | None:
Expand All @@ -149,6 +151,7 @@ def quantum_instance(self) -> QuantumInstance | None:
@deprecate_func(
additional_msg="See https://qisk.it/algo_migration for a migration guide.",
since="0.24.0",
package_name="qiskit-terra",
is_property=True,
)
def quantum_instance(self, quantum_instance: QuantumInstance | Backend) -> None:
Expand Down
3 changes: 3 additions & 0 deletions qiskit/algorithms/amplitude_estimators/fae.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class FasterAmplitudeEstimation(AmplitudeEstimator):
"migration guide."
),
since="0.24.0",
package_name="qiskit-terra",
)
def __init__(
self,
Expand Down Expand Up @@ -112,6 +113,7 @@ def sampler(self, sampler: BaseSampler) -> None:
@property
@deprecate_func(
since="0.24.0",
package_name="qiskit-terra",
is_property=True,
additional_msg="See https://qisk.it/algo_migration for a migration guide.",
)
Expand All @@ -126,6 +128,7 @@ def quantum_instance(self) -> QuantumInstance | None:
@quantum_instance.setter
@deprecate_func(
since="0.24.0",
package_name="qiskit-terra",
is_property=True,
additional_msg="See https://qisk.it/algo_migration for a migration guide.",
)
Expand Down
3 changes: 3 additions & 0 deletions qiskit/algorithms/amplitude_estimators/iae.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class IterativeAmplitudeEstimation(AmplitudeEstimator):
"migration guide."
),
since="0.24.0",
package_name="qiskit-terra",
)
def __init__(
self,
Expand Down Expand Up @@ -135,6 +136,7 @@ def sampler(self, sampler: BaseSampler) -> None:
@property
@deprecate_func(
since="0.24.0",
package_name="qiskit-terra",
is_property=True,
additional_msg="See https://qisk.it/algo_migration for a migration guide.",
)
Expand All @@ -149,6 +151,7 @@ def quantum_instance(self) -> QuantumInstance | None:
@quantum_instance.setter
@deprecate_func(
since="0.24.0",
package_name="qiskit-terra",
is_property=True,
additional_msg="See https://qisk.it/algo_migration for a migration guide.",
)
Expand Down
3 changes: 3 additions & 0 deletions qiskit/algorithms/amplitude_estimators/mlae.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class in named ``MaximumLikelihoodAmplitudeEstimation``.
"migration guide."
),
since="0.24.0",
package_name="qiskit-terra",
)
def __init__(
self,
Expand Down Expand Up @@ -139,6 +140,7 @@ def sampler(self, sampler: BaseSampler) -> None:
@property
@deprecate_func(
since="0.24.0",
package_name="qiskit-terra",
is_property=True,
additional_msg="See https://qisk.it/algo_migration for a migration guide.",
)
Expand All @@ -153,6 +155,7 @@ def quantum_instance(self) -> QuantumInstance | None:
@quantum_instance.setter
@deprecate_func(
since="0.24.0",
package_name="qiskit-terra",
is_property=True,
additional_msg="See https://qisk.it/algo_migration for a migration guide.",
)
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 @@ -38,6 +38,7 @@
"https://qisk.it/algo_migration for a migration guide."
),
since="0.24.0",
package_name="qiskit-terra",
)
def eval_observables(
quantum_instance: QuantumInstance | Backend,
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 @@ -54,6 +54,7 @@ class NumPyEigensolver(Eigensolver):
"See https://qisk.it/algo_migration for a migration guide."
),
since="0.24.0",
package_name="qiskit-terra",
)
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 @@ -103,6 +103,7 @@ class VQD(VariationalAlgorithm, Eigensolver):
"See https://qisk.it/algo_migration for a migration guide."
),
since="0.24.0",
package_name="qiskit-terra",
)
def __init__(
self,
Expand Down Expand Up @@ -781,6 +782,7 @@ class VQDResult(VariationalResult, EigensolverResult):
"See https://qisk.it/algo_migration for a migration guide."
),
since="0.24.0",
package_name="qiskit-terra",
)
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:
"See https://qisk.it/algo_migration for a migration guide."
),
since="0.24.0",
package_name="qiskit-terra",
)
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):
"See https://qisk.it/algo_migration for a migration guide."
),
since="0.24.0",
package_name="qiskit-terra",
)
def __init__(
self,
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):
"See https://qisk.it/algo_migration for a migration guide."
),
since="0.24.0",
package_name="qiskit-terra",
)
def __init__(self) -> None:
pass
Expand Down
1 change: 1 addition & 0 deletions qiskit/algorithms/evolvers/trotterization/trotter_qrte.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class TrotterQRTE(RealEvolver):
" See https://qisk.it/algo_migration for a migration guide."
),
since="0.24.0",
package_name="qiskit-terra",
)
def __init__(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class MinimumEigensolver(ABC):
"See https://qisk.it/algo_migration for a migration guide."
),
since="0.24.0",
package_name="qiskit-terra",
)
def __init__(self) -> None:
pass
Expand Down Expand Up @@ -100,6 +101,7 @@ class MinimumEigensolverResult(AlgorithmResult):
"See https://qisk.it/algo_migration for a migration guide."
),
since="0.24.0",
package_name="qiskit-terra",
)
def __init__(self) -> None:
super().__init__()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class NumPyMinimumEigensolver(MinimumEigensolver):
"See https://qisk.it/algo_migration for a migration guide."
),
since="0.24.0",
package_name="qiskit-terra",
)
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 @@ -67,6 +67,7 @@ class QAOA(VQE):
"See https://qisk.it/algo_migration for a migration guide."
),
since="0.24.0",
package_name="qiskit-terra",
)
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:
"See https://qisk.it/algo_migration for a migration guide."
),
since="0.24.0",
package_name="qiskit-terra",
)
def __init__(
self,
Expand Down Expand Up @@ -674,6 +675,7 @@ class VQEResult(VariationalResult, MinimumEigensolverResult):
"See https://qisk.it/algo_migration for a migration guide."
),
since="0.24.0",
package_name="qiskit-terra",
)
def __init__(self) -> None:
with warnings.catch_warnings():
Expand Down
3 changes: 3 additions & 0 deletions qiskit/algorithms/minimum_eigensolvers/adapt_vqe.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class AdaptVQE(VariationalAlgorithm, MinimumEigensolver):
@deprecate_arg(
"threshold",
since="0.24.0",
package_name="qiskit-terra",
pending=True,
new_alias="gradient_threshold",
)
Expand Down Expand Up @@ -146,6 +147,7 @@ def __init__(
@property
@deprecate_func(
since="0.24.0",
package_name="qiskit-terra",
pending=True,
is_property=True,
additional_msg="Instead, use the gradient_threshold attribute.",
Expand All @@ -161,6 +163,7 @@ def threshold(self) -> float:
@threshold.setter
@deprecate_func(
since="0.24.0",
package_name="qiskit-terra",
pending=True,
is_property=True,
additional_msg="Instead, use the gradient_threshold attribute.",
Expand Down
10 changes: 7 additions & 3 deletions qiskit/algorithms/optimizers/adam_amsgrad.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,13 @@ def load_params(self, load_dir: str) -> None:
t = t[1:-1]
self._t = np.fromstring(t, dtype=int, sep=" ")

@deprecate_arg("objective_function", new_alias="fun", since="0.19.0")
@deprecate_arg("initial_point", new_alias="fun", since="0.19.0")
@deprecate_arg("gradient_function", new_alias="jac", since="0.19.0")
@deprecate_arg(
"objective_function", new_alias="fun", since="0.19.0", package_name="qiskit-terra"
)
@deprecate_arg("initial_point", new_alias="fun", since="0.19.0", package_name="qiskit-terra")
@deprecate_arg(
"gradient_function", new_alias="jac", since="0.19.0", package_name="qiskit-terra"
)
def minimize(
self,
fun: Callable[[POINT], float],
Expand Down
2 changes: 2 additions & 0 deletions qiskit/algorithms/optimizers/qnspsa.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ def settings(self) -> dict[str, Any]:
@deprecate_arg(
"backend",
since="0.24.0",
package_name="qiskit-terra",
additional_msg="See https://qisk.it/algo_migration for a migration guide.",
# We allow passing a sampler as the second argument because that will become a positional
# argument for `sampler` after removing `backend` and `expectation`.
Expand All @@ -266,6 +267,7 @@ def settings(self) -> dict[str, Any]:
@deprecate_arg(
"expectation",
since="0.24.0",
package_name="qiskit-terra",
additional_msg="See https://qisk.it/algo_migration for a migration guide.",
)
def get_fidelity(
Expand Down
1 change: 1 addition & 0 deletions qiskit/algorithms/optimizers/spsa.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,7 @@ def get_support_level(self):
"containing additional information."
),
since="0.21.0",
package_name="qiskit-terra",
)
def optimize(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ class HamiltonianPhaseEstimation:
"migration guide."
),
since="0.24.0",
package_name="qiskit-terra",
)
def __init__(
self,
Expand Down
1 change: 1 addition & 0 deletions qiskit/algorithms/phase_estimators/ipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class IterativePhaseEstimation(PhaseEstimator):
"migration guide."
),
since="0.24.0",
package_name="qiskit-terra",
)
def __init__(
self,
Expand Down
1 change: 1 addition & 0 deletions qiskit/algorithms/phase_estimators/phase_estimation.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class PhaseEstimation(PhaseEstimator):
"migration guide."
),
since="0.24.0",
package_name="qiskit-terra",
)
def __init__(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def circuit_result(self) -> Result:
@deprecate_func(
additional_msg="Instead, use the property ``phase``, which behaves the same.",
since="0.18.0",
package_name="qiskit-terra",
is_property=True,
)
def most_likely_phase(self) -> float:
Expand Down
2 changes: 2 additions & 0 deletions qiskit/circuit/bit.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def __init__(self, register=None, index=None):
@deprecate_func(
is_property=True,
since="0.17",
package_name="qiskit-terra",
additional_msg=(
"Instead, use :meth:`~qiskit.circuit.quantumcircuit.QuantumCircuit.find_bit` to find "
"all the containing registers within a circuit and the index of the bit within the "
Expand All @@ -85,6 +86,7 @@ def register(self): # pylint: disable=bad-docstring-quotes
@deprecate_func(
is_property=True,
since="0.17",
package_name="qiskit-terra",
additional_msg=(
"Instead, use :meth:`~qiskit.circuit.quantumcircuit.QuantumCircuit.find_bit` to find "
"all the containing registers within a circuit and the index of the bit within the "
Expand Down
1 change: 1 addition & 0 deletions qiskit/circuit/classicalregister.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class ClassicalRegister(Register):
"provided, because the premise is wrong."
),
since="0.23.0",
package_name="qiskit-terra",
)
def qasm(self):
"""Return OPENQASM string for this register."""
Expand Down
1 change: 1 addition & 0 deletions qiskit/circuit/instruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,7 @@ def _qasmif(self, string):
"provided, because the premise is wrong."
),
since="0.25.0",
package_name="qiskit-terra",
)
def qasm(self):
"""Return a default OpenQASM string for the instruction.
Expand Down
1 change: 1 addition & 0 deletions qiskit/circuit/library/hamiltonian_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ def _define(self):

@deprecate_func(
since="0.25.0",
package_name="qiskit-terra",
)
def qasm(self):
"""Raise an error, as QASM is not defined for the HamiltonianGate."""
Expand Down
2 changes: 1 addition & 1 deletion qiskit/circuit/library/standard_gates/x.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ def _define(self):

self.definition = qc

@deprecate_func(since="0.25.0")
@deprecate_func(since="0.25.0", package_name="qiskit-terra")
def qasm(self):
# Gross hack to override the Qiskit name with the name this gate has in Terra's version of
# 'qelib1.inc'. In general, the larger exporter mechanism should know about this to do the
Expand Down
Loading

0 comments on commit 5a948c2

Please sign in to comment.