Skip to content

Commit

Permalink
Merge from main, apply algo deprecation, use assertWarns instead of w…
Browse files Browse the repository at this point in the history
…arnings
  • Loading branch information
ElePT committed Apr 17, 2023
2 parents bd9090f + 3ebef17 commit 2613874
Show file tree
Hide file tree
Showing 57 changed files with 1,209 additions and 1,586 deletions.
20 changes: 10 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/accelerate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ rustworkx-core = "0.12"
# The base version of PyO3 and setting a minimum feature set (e.g. probably just 'extension-module')
# can be done in the workspace and inherited once we hit Rust 1.64.
[dependencies.pyo3]
version = "0.18.2"
version = "0.18.3"
features = ["extension-module", "hashbrown", "indexmap", "num-complex", "num-bigint"]

[dependencies.ndarray]
Expand Down
2 changes: 1 addition & 1 deletion crates/qasm2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ crate-type = ["cdylib"]

[dependencies]
hashbrown = "0.13.2"
pyo3 = { version = "0.18.2", features = ["extension-module"] }
pyo3 = { version = "0.18.3", features = ["extension-module"] }
28 changes: 19 additions & 9 deletions qiskit/algorithms/amplitude_amplifiers/grover.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,11 @@ class Grover(AmplitudeAmplifier):

@deprecate_arg(
"quantum_instance",
additional_msg="Instead, use the ``sampler`` argument.",
since="0.22.0",
pending=True,
additional_msg=(
"Instead, use the ``sampler`` argument. "
"See https://qisk.it/algo_migration for a migration guide."
),
since="0.24.0",
)
def __init__(
self,
Expand All @@ -145,7 +147,7 @@ def __init__(
sample_from_iterations: If True, instead of taking the values in ``iterations`` as
powers of the Grover operator, a random integer sample between 0 and smaller value
than the iteration is used as a power, see [1], Section 4.
quantum_instance: Pending deprecation: A Quantum Instance or Backend to run the circuits.
quantum_instance: Deprecated: A Quantum Instance or Backend to run the circuits.
sampler: A Sampler to use for sampling the results of the circuits.
Raises:
Expand Down Expand Up @@ -185,7 +187,7 @@ def __init__(
self._quantum_instance: QuantumInstance | None = None
if quantum_instance is not None:
with warnings.catch_warnings():
warnings.simplefilter("ignore", category=PendingDeprecationWarning)
warnings.simplefilter("ignore", DeprecationWarning)
self.quantum_instance = quantum_instance

self._sampler = sampler
Expand All @@ -194,19 +196,27 @@ def __init__(
self._iterations_arg = iterations

@property
@deprecate_func(since="0.23.0", pending=True, is_property=True)
@deprecate_func(
since="0.24.0",
is_property=True,
additional_msg="See https://qisk.it/algo_migration for a migration guide.",
)
def quantum_instance(self) -> QuantumInstance | None:
r"""Pending deprecation\; Get the quantum instance.
r"""Deprecated. Get the quantum instance.
Returns:
The quantum instance used to run this algorithm.
"""
return self._quantum_instance

@quantum_instance.setter
@deprecate_func(since="0.23.0", pending=True, is_property=True)
@deprecate_func(
since="0.24.0",
is_property=True,
additional_msg="See https://qisk.it/algo_migration for a migration guide.",
)
def quantum_instance(self, quantum_instance: QuantumInstance | Backend) -> None:
r"""Pending deprecation\; Set quantum instance.
r"""Deprecated. Set quantum instance.
Args:
quantum_instance: The quantum instance used to run this algorithm.
Expand Down
26 changes: 18 additions & 8 deletions qiskit/algorithms/amplitude_estimators/ae.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,11 @@ class AmplitudeEstimation(AmplitudeEstimator):

@deprecate_arg(
"quantum_instance",
additional_msg="Instead, use the ``sampler`` argument.",
since="0.22.0",
pending=True,
additional_msg=(
"Instead, use the ``sampler`` argument. See https://qisk.it/algo_migration for a "
"migration guide."
),
since="0.24.0",
)
def __init__(
self,
Expand All @@ -86,7 +88,7 @@ def __init__(
`qiskit.circuit.library.PhaseEstimation` when None.
iqft: The inverse quantum Fourier transform component, defaults to using a standard
implementation from `qiskit.circuit.library.QFT` when None.
quantum_instance: Pending deprecation\: The backend (or `QuantumInstance`) to execute
quantum_instance: Deprecated: The backend (or `QuantumInstance`) to execute
the circuits on.
sampler: A sampler primitive to evaluate the circuits.
Expand Down Expand Up @@ -130,19 +132,27 @@ def sampler(self, sampler: BaseSampler) -> None:
self._sampler = sampler

@property
@deprecate_func(since="0.23.0", pending=True, is_property=True)
@deprecate_func(
additional_msg="See https://qisk.it/algo_migration for a migration guide.",
since="0.24.0",
is_property=True,
)
def quantum_instance(self) -> QuantumInstance | None:
"""Pending deprecation; Get the quantum instance.
"""Deprecated: Get the quantum instance.
Returns:
The quantum instance used to run this algorithm.
"""
return self._quantum_instance

@quantum_instance.setter
@deprecate_func(since="0.23.0", pending=True, is_property=True)
@deprecate_func(
additional_msg="See https://qisk.it/algo_migration for a migration guide.",
since="0.24.0",
is_property=True,
)
def quantum_instance(self, quantum_instance: QuantumInstance | Backend) -> None:
"""Pending deprecation; Set quantum instance.
"""Deprecated: Set quantum instance.
Args:
quantum_instance: The quantum instance used to run this algorithm.
Expand Down
26 changes: 18 additions & 8 deletions qiskit/algorithms/amplitude_estimators/fae.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ class FasterAmplitudeEstimation(AmplitudeEstimator):

@deprecate_arg(
"quantum_instance",
additional_msg="Instead, use the ``sampler`` argument.",
since="0.22.0",
pending=True,
additional_msg=(
"Instead, use the ``sampler`` argument. See https://qisk.it/algo_migration for a "
"migration guide."
),
since="0.24.0",
)
def __init__(
self,
Expand All @@ -67,7 +69,7 @@ def __init__(
delta: The probability that the true value is outside of the final confidence interval.
maxiter: The number of iterations, the maximal power of Q is `2 ** (maxiter - 1)`.
rescale: Whether to rescale the problem passed to `estimate`.
quantum_instance: Pending deprecation\: The quantum instance or backend
quantum_instance: Deprecated: The quantum instance or backend
to run the circuits.
sampler: A sampler primitive to evaluate the circuits.
Expand Down Expand Up @@ -108,19 +110,27 @@ def sampler(self, sampler: BaseSampler) -> None:
self._sampler = sampler

@property
@deprecate_func(since="0.23.0", pending=True, is_property=True)
@deprecate_func(
since="0.24.0",
is_property=True,
additional_msg="See https://qisk.it/algo_migration for a migration guide.",
)
def quantum_instance(self) -> QuantumInstance | None:
"""Pending deprecation; Get the quantum instance.
"""Deprecated. Get the quantum instance.
Returns:
The quantum instance used to run this algorithm.
"""
return self._quantum_instance

@quantum_instance.setter
@deprecate_func(since="0.23.0", pending=True, is_property=True)
@deprecate_func(
since="0.24.0",
is_property=True,
additional_msg="See https://qisk.it/algo_migration for a migration guide.",
)
def quantum_instance(self, quantum_instance: QuantumInstance | Backend) -> None:
"""Pending deprecation; Set quantum instance.
"""Deprecated. Set quantum instance.
Args:
quantum_instance: The quantum instance used to run this algorithm.
Expand Down
26 changes: 18 additions & 8 deletions qiskit/algorithms/amplitude_estimators/iae.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ class IterativeAmplitudeEstimation(AmplitudeEstimator):

@deprecate_arg(
"quantum_instance",
additional_msg="Instead, use the ``sampler`` argument.",
since="0.22.0",
pending=True,
additional_msg=(
"Instead, use the ``sampler`` argument. See https://qisk.it/algo_migration for a "
"migration guide."
),
since="0.24.0",
)
def __init__(
self,
Expand All @@ -77,7 +79,7 @@ def __init__(
each iteration, can be 'chernoff' for the Chernoff intervals or 'beta' for the
Clopper-Pearson intervals (default)
min_ratio: Minimal q-ratio (:math:`K_{i+1} / K_i`) for FindNextK
quantum_instance: Pending deprecation\: Quantum Instance or Backend
quantum_instance: Deprecated: Quantum Instance or Backend
sampler: A sampler primitive to evaluate the circuits.
Raises:
Expand Down Expand Up @@ -131,19 +133,27 @@ def sampler(self, sampler: BaseSampler) -> None:
self._sampler = sampler

@property
@deprecate_func(since="0.23.0", pending=True, is_property=True)
@deprecate_func(
since="0.24.0",
is_property=True,
additional_msg="See https://qisk.it/algo_migration for a migration guide.",
)
def quantum_instance(self) -> QuantumInstance | None:
"""Pending deprecation; Get the quantum instance.
"""Deprecated. Get the quantum instance.
Returns:
The quantum instance used to run this algorithm.
"""
return self._quantum_instance

@quantum_instance.setter
@deprecate_func(since="0.23.0", pending=True, is_property=True)
@deprecate_func(
since="0.24.0",
is_property=True,
additional_msg="See https://qisk.it/algo_migration for a migration guide.",
)
def quantum_instance(self, quantum_instance: QuantumInstance | Backend) -> None:
"""Pending deprecation; Set quantum instance.
"""Deprecated. Set quantum instance.
Args:
quantum_instance: The quantum instance used to run this algorithm.
Expand Down
26 changes: 18 additions & 8 deletions qiskit/algorithms/amplitude_estimators/mlae.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@ class in named ``MaximumLikelihoodAmplitudeEstimation``.

@deprecate_arg(
"quantum_instance",
additional_msg="Instead, use the ``sampler`` argument.",
since="0.22.0",
pending=True,
additional_msg=(
"Instead, use the ``sampler`` argument. See https://qisk.it/algo_migration for a "
"migration guide."
),
since="0.24.0",
)
def __init__(
self,
Expand All @@ -77,7 +79,7 @@ def __init__(
according to ``evaluation_schedule``. The minimizer takes a function as first
argument and a list of (float, float) tuples (as bounds) as second argument and
returns a single float which is the found minimum.
quantum_instance: Pending deprecation\: Quantum Instance or Backend
quantum_instance: Deprecated: Quantum Instance or Backend
sampler: A sampler primitive to evaluate the circuits.
Raises:
Expand Down Expand Up @@ -135,19 +137,27 @@ def sampler(self, sampler: BaseSampler) -> None:
self._sampler = sampler

@property
@deprecate_func(since="0.23.0", pending=True, is_property=True)
@deprecate_func(
since="0.24.0",
is_property=True,
additional_msg="See https://qisk.it/algo_migration for a migration guide.",
)
def quantum_instance(self) -> QuantumInstance | None:
"""Pending deprecation; Get the quantum instance.
"""Deprecated. Get the quantum instance.
Returns:
The quantum instance used to run this algorithm.
"""
return self._quantum_instance

@quantum_instance.setter
@deprecate_func(since="0.23.0", pending=True, is_property=True)
@deprecate_func(
since="0.24.0",
is_property=True,
additional_msg="See https://qisk.it/algo_migration for a migration guide.",
)
def quantum_instance(self, quantum_instance: QuantumInstance | Backend) -> None:
"""Pending deprecation; Set quantum instance.
"""Deprecated. Set quantum instance.
Args:
quantum_instance: The quantum instance used to run this algorithm.
Expand Down
8 changes: 4 additions & 4 deletions qiskit/algorithms/aux_ops_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
@deprecate_func(
additional_msg=(
"Instead, use the function "
"``qiskit.algorithms.observables_evaluator.estimate_observables``."
"``qiskit.algorithms.observables_evaluator.estimate_observables``. See "
"https://qisk.it/algo_migration for a migration guide."
),
since="0.23.0",
pending=True,
since="0.24.0",
)
def eval_observables(
quantum_instance: QuantumInstance | Backend,
Expand All @@ -47,7 +47,7 @@ def eval_observables(
threshold: float = 1e-12,
) -> ListOrDict[tuple[complex, complex]]:
"""
Pending deprecation: Accepts a list or a dictionary of operators and calculates
Deprecated: Accepts a list or a dictionary of operators and calculates
their expectation values - means
and standard deviations. They are calculated with respect to a quantum state provided. A user
can optionally provide a threshold value which filters mean values falling below the threshold.
Expand Down
Loading

0 comments on commit 2613874

Please sign in to comment.