Skip to content

Commit

Permalink
Remove deprecated methods in qiskit.algorithms (#7257)
Browse files Browse the repository at this point in the history
* rm deprecated algo methods

* add reno

* fix tests, remove from varalgo

* intial point was said to be abstract in varalgo!

* attempt to fix sphinx #1 of ?

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
Cryoris and mergify[bot] authored Mar 1, 2022
1 parent ccc371f commit bee5e7f
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 448 deletions.
60 changes: 0 additions & 60 deletions qiskit/algorithms/minimum_eigen_solvers/vqe.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
from qiskit.opflow.gradients import GradientBase
from qiskit.utils.validation import validate_min
from qiskit.utils.backend_utils import is_aer_provider
from qiskit.utils.deprecation import deprecate_function
from qiskit.utils import QuantumInstance, algorithm_globals
from ..optimizers import Optimizer, SLSQP
from ..variational_algorithm import VariationalAlgorithm, VariationalResult
Expand Down Expand Up @@ -648,51 +647,6 @@ def energy_evaluation(parameters):

return energy_evaluation

@deprecate_function(
"""
The VQE.get_optimal_cost method is deprecated as of Qiskit Terra 0.18.0
and will be removed no sooner than 3 months after the releasedate.
This information is part of the returned result object and can be
queried as VQEResult.eigenvalue."""
)
def get_optimal_cost(self) -> float:
"""Get the minimal cost or energy found by the VQE."""
if self._ret.optimal_point is None:
raise AlgorithmError(
"Cannot return optimal cost before running the algorithm to find optimal params."
)
return self._ret.optimal_value

@deprecate_function(
"""
The VQE.get_optimal_circuit method is deprecated as of Qiskit Terra
0.18.0 and will be removed no sooner than 3 months after the releasedate.
This information is part of the returned result object and can be
queried as VQEResult.ansatz.bind_parameters(VQEResult.optimal_point)."""
)
def get_optimal_circuit(self) -> QuantumCircuit:
"""Get the circuit with the optimal parameters."""
if self._ret.optimal_point is None:
raise AlgorithmError(
"Cannot find optimal circuit before running the algorithm to find optimal params."
)
return self.ansatz.assign_parameters(self._ret.optimal_parameters)

@deprecate_function(
"""
The VQE.get_optimal_vector method is deprecated as of Qiskit Terra 0.18.0
and will be removed no sooner than 3 months after the releasedate.
This information is part of the returned result object and can be
queried as VQEResult.eigenvector."""
)
def get_optimal_vector(self) -> Union[List[float], Dict[str, int]]:
"""Get the simulation outcome of the optimal circuit."""
if self._ret.optimal_parameters is None:
raise AlgorithmError(
"Cannot find optimal circuit before running the algorithm to find optimal vector."
)
return self._get_eigenstate(self._ret.optimal_parameters)

def _get_eigenstate(self, optimal_parameters) -> Union[List[float], Dict[str, int]]:
"""Get the simulation outcome of the ansatz, provided with parameters."""
optimal_circuit = self.ansatz.bind_parameters(optimal_parameters)
Expand All @@ -704,20 +658,6 @@ def _get_eigenstate(self, optimal_parameters) -> Union[List[float], Dict[str, in

return state

@property
@deprecate_function(
"""
The VQE.optimal_params property is deprecated as of Qiskit Terra 0.18.0
and will be removed no sooner than 3 months after the releasedate.
This information is part of the returned result object and can be
queried as VQEResult.optimal_point."""
)
def optimal_params(self) -> np.ndarray:
"""The optimal parameters for the ansatz."""
if self._ret.optimal_point is None:
raise AlgorithmError("Cannot find optimal params before running the algorithm.")
return self._ret.optimal_point


class VQEResult(VariationalResult, MinimumEigensolverResult):
"""VQE Result."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@


from typing import Dict, Union, cast
from qiskit.utils.deprecation import deprecate_function
from qiskit.algorithms.algorithm_result import AlgorithmResult
from .phase_estimation_result import PhaseEstimationResult
from .phase_estimation_scale import PhaseEstimationScale
Expand Down Expand Up @@ -84,20 +83,6 @@ def filter_phases(
else:
return cast(Dict, phases)

@property
@deprecate_function(
"""The 'HamiltonianPhaseEstimationResult.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."""
)
def most_likely_phase(self) -> float:
"""DEPRECATED - The most likely phase of the unitary corresponding to the Hamiltonian.
Returns:
The most likely phase.
"""
return self.phase

@property
def phase(self) -> float:
"""The most likely phase of the unitary corresponding to the Hamiltonian.
Expand Down
Loading

0 comments on commit bee5e7f

Please sign in to comment.