From 326a0841c12fbacea6f99d3bc93d94aad84a94b7 Mon Sep 17 00:00:00 2001 From: woodsp-ibm Date: Sat, 29 Jun 2024 09:15:33 -0400 Subject: [PATCH 1/3] Numpy 2.0 compatibility fix --- qiskit_algorithms/eigensolvers/numpy_eigensolver.py | 4 ++-- releasenotes/notes/numpy_2.0_fix-c29681db4874eee8.yaml | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/numpy_2.0_fix-c29681db4874eee8.yaml diff --git a/qiskit_algorithms/eigensolvers/numpy_eigensolver.py b/qiskit_algorithms/eigensolvers/numpy_eigensolver.py index d1aef88c..b5deb93a 100644 --- a/qiskit_algorithms/eigensolvers/numpy_eigensolver.py +++ b/qiskit_algorithms/eigensolvers/numpy_eigensolver.py @@ -1,6 +1,6 @@ # This code is part of a Qiskit project. # -# (C) Copyright IBM 2022, 2023. +# (C) Copyright IBM 2022, 2024. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory @@ -152,7 +152,7 @@ def _solve(self, operator: BaseOperator) -> tuple[np.ndarray, np.ndarray]: @staticmethod def _solve_sparse(op_matrix: scisparse.csr_matrix, k: int) -> tuple[np.ndarray, np.ndarray]: - if (op_matrix != op_matrix.H).nnz == 0: + if (op_matrix != op_matrix.getH()).nnz == 0: # Operator is Hermitian return scisparse.linalg.eigsh(op_matrix, k=k, which="SA") else: diff --git a/releasenotes/notes/numpy_2.0_fix-c29681db4874eee8.yaml b/releasenotes/notes/numpy_2.0_fix-c29681db4874eee8.yaml new file mode 100644 index 00000000..2411c7bc --- /dev/null +++ b/releasenotes/notes/numpy_2.0_fix-c29681db4874eee8.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Compatibility fix for numpy 2.0 version. csr_matrix.H had been deprecated + and was removed in 2.0. The :class:`.NumPyEigensolver` algorithm, which + had been using that, has been updated to use an alternative. From e3be664e5e6561c463be9087e5d027a67abb2acf Mon Sep 17 00:00:00 2001 From: woodsp-ibm Date: Sat, 29 Jun 2024 09:37:58 -0400 Subject: [PATCH 2/3] Numpy 2.0 compatibility fix --- .pylintdict | 1 + 1 file changed, 1 insertion(+) diff --git a/.pylintdict b/.pylintdict index 257e3f66..f4d90d78 100644 --- a/.pylintdict +++ b/.pylintdict @@ -52,6 +52,7 @@ configs confint córcoles crs +csr currentmodule customizable cvar From 2ce736285f0fa4fbe44612197143deed579ad4bc Mon Sep 17 00:00:00 2001 From: woodsp-ibm Date: Sat, 29 Jun 2024 09:40:59 -0400 Subject: [PATCH 3/3] Scipy 1.14 compatibility fix --- releasenotes/notes/numpy_2.0_fix-c29681db4874eee8.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/releasenotes/notes/numpy_2.0_fix-c29681db4874eee8.yaml b/releasenotes/notes/numpy_2.0_fix-c29681db4874eee8.yaml index 2411c7bc..cbeed03d 100644 --- a/releasenotes/notes/numpy_2.0_fix-c29681db4874eee8.yaml +++ b/releasenotes/notes/numpy_2.0_fix-c29681db4874eee8.yaml @@ -1,6 +1,6 @@ --- fixes: - | - Compatibility fix for numpy 2.0 version. csr_matrix.H had been deprecated - and was removed in 2.0. The :class:`.NumPyEigensolver` algorithm, which + Compatibility fix for scipy 1.14 version. csr_matrix.H had been deprecated + and was removed. The :class:`.NumPyEigensolver` algorithm, which had been using that, has been updated to use an alternative.