From cf82481edf806670ebf8461ddf470cfe9b0c6770 Mon Sep 17 00:00:00 2001 From: Ryosuke Noro <64354442+RyosukeNORO@users.noreply.github.com> Date: Fri, 5 Jul 2024 15:29:47 -0400 Subject: [PATCH] added pylint: disable=too-many-return-statements. fixed the ordering of the matrix in takagi with diagonal matrix --- thewalrus/decompositions.py | 8 +++++--- thewalrus/tests/test_decompositions.py | 8 +------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/thewalrus/decompositions.py b/thewalrus/decompositions.py index 0dfee9f7..a8ae2d3e 100644 --- a/thewalrus/decompositions.py +++ b/thewalrus/decompositions.py @@ -153,6 +153,7 @@ def blochmessiah(S): def takagi(A, svd_order=True): + # pylint: disable=too-many-return-statements r"""Autonne-Takagi decomposition of a complex symmetric (not Hermitian!) matrix. Note that the input matrix is internally symmetrized by taking its upper triangular part. If the input matrix is indeed symmetric this leaves it unchanged. @@ -207,10 +208,11 @@ def takagi(A, svd_order=True): d = np.diag(A) U = np.diag(np.exp(1j * 0.5 * np.angle(d))) l = np.abs(d) - l = np.sort(l) - U = U[np.argsort(l)] + idx = np.argsort(l) + l = l[idx] + U = U[idx] if svd_order: - return l[::-1], U[:, ::-1] + return l[::-1], U[::-1, :] return l, U u, d, v = np.linalg.svd(A) diff --git a/thewalrus/tests/test_decompositions.py b/thewalrus/tests/test_decompositions.py index 7f969a59..5da07ac0 100644 --- a/thewalrus/tests/test_decompositions.py +++ b/thewalrus/tests/test_decompositions.py @@ -19,13 +19,7 @@ from thewalrus.random import random_interferometer as haar_measure from thewalrus.random import random_symplectic -from thewalrus.decompositions import ( - williamson, - blochmessiah, - takagi, - pre_iwasawa, - iwasawa, -) +from thewalrus.decompositions import williamson, blochmessiah, takagi, pre_iwasawa, iwasawa from thewalrus.symplectic import sympmat as omega from thewalrus.quantum.gaussian_checks import is_symplectic