From 3fb69b3051f39602b1e4c3f0229a849a2ff6b8e4 Mon Sep 17 00:00:00 2001 From: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com> Date: Sat, 6 Jul 2024 08:49:39 -0400 Subject: [PATCH] Scipy 1.14 compatibility fix (#184) --- .pylintdict | 1 + qiskit_algorithms/eigensolvers/numpy_eigensolver.py | 4 ++-- releasenotes/notes/numpy_2.0_fix-c29681db4874eee8.yaml | 6 ++++++ 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/numpy_2.0_fix-c29681db4874eee8.yaml 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 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..cbeed03d --- /dev/null +++ b/releasenotes/notes/numpy_2.0_fix-c29681db4874eee8.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + 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.