From e53fcd52accba4a959d4d3fad9715364ed6c4ddb Mon Sep 17 00:00:00 2001 From: Joris Snellenburg Date: Sun, 18 Aug 2024 20:18:39 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20ordering=20bug=20in=20Matr?= =?UTF-8?q?ixProvider=20class=20(#1512)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ๐Ÿฉน Fix bug in matrix provider Fix ordering issue in the case of multiple types of different megacomplexes were combined in the MatrixProvider class. * ๐Ÿ“š Updated changelog --- changelog.md | 4 ++++ glotaran/optimization/matrix_provider.py | 7 ++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/changelog.md b/changelog.md index 6a0a95eb1..a9a5d3d80 100644 --- a/changelog.md +++ b/changelog.md @@ -8,6 +8,10 @@ - โœจ Add official Python 3.12 support (#1437) +### ๐Ÿฉน Bug fixes + +- ๐Ÿฉน Fix ordering bug in MatrixProvider class (#1512) + ### ๐Ÿšง Maintenance -๐Ÿงน๐Ÿš‡ Remove asv benchmarks and binder integration diff --git a/glotaran/optimization/matrix_provider.py b/glotaran/optimization/matrix_provider.py index df90dba70..40042efe8 100644 --- a/glotaran/optimization/matrix_provider.py +++ b/glotaran/optimization/matrix_provider.py @@ -222,14 +222,15 @@ def combine_megacomplex_matrices( tuple[list[str], ArrayLike]: The combined clp labels and matrix. """ + if len(matrix_left.shape) < len(matrix_right.shape): + matrix_left, matrix_right = matrix_right, matrix_left + clp_labels_left, clp_labels_right = clp_labels_right, clp_labels_left + result_clp_labels = clp_labels_left + [ c for c in clp_labels_right if c not in clp_labels_left ] result_clp_size = len(result_clp_labels) - if len(matrix_left.shape) < len(matrix_right.shape): - matrix_left, matrix_right = matrix_right, matrix_left - left_index_dependent = len(matrix_left.shape) == 3 right_index_dependent = len(matrix_right.shape) == 3