Skip to content

Commit

Permalink
remove Optimizer from aqc
Browse files Browse the repository at this point in the history
  • Loading branch information
ShellyGarion committed Jan 23, 2024
1 parent 93183a7 commit 63d1ca2
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 25 deletions.
16 changes: 1 addition & 15 deletions qiskit/synthesis/unitary/aqc/aqc.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import numpy as np
from scipy.optimize import OptimizeResult, minimize

from qiskit.algorithms.optimizers import Optimizer # pylint: disable=cyclic-import
from qiskit.quantum_info import Operator
from qiskit.utils.deprecation import deprecate_arg

Expand Down Expand Up @@ -102,19 +101,9 @@ class AQC:
also allocates a number of temporary memory buffers comparable in size to the target matrix.
"""

@deprecate_arg(
"optimizer",
deprecation_description=(
"Setting the `optimizer` argument to an instance "
"of `qiskit.algorithms.optimizers.Optimizer` "
),
additional_msg=("Please, submit a callable that follows the `Minimizer` protocol instead."),
predicate=lambda optimizer: isinstance(optimizer, Optimizer),
since="0.45.0",
)
def __init__(
self,
optimizer: Minimizer | Optimizer | None = None,
optimizer: Minimizer | None = None,
seed: int | None = None,
):
"""
Expand All @@ -128,9 +117,6 @@ def __init__(
self._optimizer = optimizer or partial(
minimize, args=(), method="L-BFGS-B", options={"maxiter": 1000}
)
# temporary fix -> remove after deprecation period of Optimizer
if isinstance(self._optimizer, Optimizer):
self._optimizer = self._optimizer.minimize

self._seed = seed

Expand Down
10 changes: 0 additions & 10 deletions test/python/synthesis/aqc/test_aqc.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import numpy as np
from scipy.optimize import minimize

from qiskit.algorithms.optimizers import L_BFGS_B
from qiskit.quantum_info import Operator
from qiskit.test import QiskitTestCase
from qiskit.synthesis.unitary.aqc.aqc import AQC
Expand Down Expand Up @@ -67,15 +66,6 @@ def test_aqc(self, uses_default):
error = 0.5 * (np.linalg.norm(approx_matrix - ORIGINAL_CIRCUIT, "fro") ** 2)
self.assertLess(error, 1e-3)

def test_aqc_deprecation(self):
"""Tests that AQC raises deprecation warning."""

seed = 12345
optimizer = L_BFGS_B(maxiter=200)

with self.assertRaises(DeprecationWarning):
_ = AQC(optimizer=optimizer, seed=seed)

def test_aqc_fastgrad(self):
"""
Tests AQC on a MCX circuit/matrix with random initial guess using
Expand Down

0 comments on commit 63d1ca2

Please sign in to comment.