From 8725233aaf383f10e783fe2347f827572451a504 Mon Sep 17 00:00:00 2001 From: woodsp-ibm Date: Thu, 5 Oct 2023 14:34:14 -0400 Subject: [PATCH 1/2] Remove numpy 1.25 constraint --- constraints.txt | 5 +---- qiskit_algorithms/optimizers/snobfit.py | 3 +-- 2 files changed, 2 insertions(+), 6 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." From ad62800b47381b60b421f015958c0d4e944f9978 Mon Sep 17 00:00:00 2001 From: woodsp-ibm Date: Thu, 5 Oct 2023 15:30:10 -0400 Subject: [PATCH 2/2] Alter SPSA ignore - mypy failures for newer numpy --- qiskit_algorithms/optimizers/spsa.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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