From d19d7e65a4bcee44585bdc6bf38431fe63916a21 Mon Sep 17 00:00:00 2001 From: Joris Snellenburg Date: Mon, 28 Nov 2022 01:57:13 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9Fix=20matrix=20provider?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- glotaran/optimization/matrix_provider.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/glotaran/optimization/matrix_provider.py b/glotaran/optimization/matrix_provider.py index f13c9d1cf..4dfa562f1 100644 --- a/glotaran/optimization/matrix_provider.py +++ b/glotaran/optimization/matrix_provider.py @@ -653,11 +653,20 @@ def calculate_aligned_matrices(self): # old: reduce_matrix(MatrixContainers, index) -> MatrixContainers full_clp_labels = self.align_full_clp_labels() for i, global_index_value in enumerate(self._data_provider.aligned_global_axis): + matrix_containers = [] group_label = self._data_provider.get_aligned_group_label(i) - matrix_containers = [ - self._matrix_containers[label] - for label in self._data_provider.group_definitions[group_label] - ] + for label, index in zip( + self._data_provider.group_definitions[group_label], + self._data_provider.get_aligned_dataset_indices(i), + ): + temp = self._matrix_containers[label] + if temp.is_index_dependent: + matrix_containers.append( + MatrixContainer(clp_labels=temp.clp_labels, matrix=temp.matrix[index]) + ) + else: + matrix_containers.append(temp) + matrix_scales = [ self.group.dataset_models[label].scale if self.group.dataset_models[label].scale is not None @@ -670,10 +679,9 @@ def calculate_aligned_matrices(self): ) self._aligned_full_clp_labels[i] = full_clp_labels[group_label] - group_matrix_for_all = self.reduce_matrix( - group_matrix, self._data_provider.aligned_global_axis - ) - group_matrix_single = group_matrix_for_all[i] + group_matrix_single = self.reduce_matrix( + group_matrix, np.array([self._data_provider.aligned_global_axis[i]]) + )[0] weight = self._data_provider.get_aligned_weight(i) if weight is not None: