From 57d21b93b3572386c140d0bde8b008489f734819 Mon Sep 17 00:00:00 2001 From: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com> Date: Mon, 9 Oct 2023 09:03:28 -0400 Subject: [PATCH] Remove numpy 1.25 constraint (#83) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Elena Peña Tapia <57907331+ElePT@users.noreply.github.com> --- constraints.txt | 5 +---- qiskit_algorithms/optimizers/snobfit.py | 3 +-- qiskit_algorithms/optimizers/spsa.py | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/constraints.txt b/constraints.txt index a442313e..248be8c7 100644 --- a/constraints.txt +++ b/constraints.txt @@ -1,5 +1,2 @@ -# Numpy 1.25 deprecated some behaviours that we used, and caused the isometry -# tests to flake. See https://github.com/Qiskit/qiskit-terra/issues/10305, -# remove pin when resolving that. -numpy<1.25 +# Constraints may be listed here diff --git a/qiskit_algorithms/optimizers/snobfit.py b/qiskit_algorithms/optimizers/snobfit.py index 9269df5f..68ab305a 100644 --- a/qiskit_algorithms/optimizers/snobfit.py +++ b/qiskit_algorithms/optimizers/snobfit.py @@ -57,8 +57,7 @@ def __init__( See https://github.com/scikit-quant/scikit-quant/issues/24 for more details. """ # check version - version = tuple(map(int, np.__version__.split("."))) - if version >= (1, 24, 0): + if tuple(map(int, np.__version__.split(".")[:2])) >= (1, 24): raise AlgorithmError( "SnobFit is incompatible with NumPy 1.24.0 or above, please " "install a previous version. See also scikit-quant/scikit-quant#24." diff --git a/qiskit_algorithms/optimizers/spsa.py b/qiskit_algorithms/optimizers/spsa.py index 79245815..eb18b618 100644 --- a/qiskit_algorithms/optimizers/spsa.py +++ b/qiskit_algorithms/optimizers/spsa.py @@ -629,7 +629,7 @@ def minimize( logger.info("SPSA: Finished in %s", time() - start) if self.last_avg > 1: - x = np.mean(last_steps, axis=0) # type: ignore[call-overload] + x = np.mean(np.asarray(last_steps), axis=0) result = OptimizerResult() result.x = x