Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🩹 Fix matrix provider #1190

Merged
merged 3 commits into from
Nov 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
- 🩹 Fix result data overwritten when using multiple dataset_groups (#1147)
- 🩹 Fix for normalization issue described in #1157 (multi-gaussian irfs and multiple time ranges (streak))
- 🩹 Fix for crash described in #1183 when doing an optimization using more than 30 datasets (#1184)
<!-- Fix within the 0.7.0 release cycle, therefore hidden:
- 🩹 Fix the matrix provider alignment/reduction ('grouping') issues introduced in #1175 (#1190)
-->


### 📚 Documentation
Expand Down
51 changes: 31 additions & 20 deletions glotaran/optimization/matrix_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,35 +644,46 @@ def calculate(self):

def calculate_aligned_matrices(self):
"""Calculate the aligned matrices of the dataset group."""
reduced_matrices = {
label: self.reduce_matrix(matrix_container, self._data_provider.get_global_axis(label))
for label, matrix_container in self._matrix_containers.items()
}
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)
self._aligned_full_clp_labels[i] = full_clp_labels[group_label]
group_matrix = self.align_matrices(
[
reduced_matrices[label][index]
for label, index in zip(
self._data_provider.group_definitions[group_label],
self._data_provider.get_aligned_dataset_indices(i),
for label, index in zip(
self._data_provider.group_definitions[group_label],
self._data_provider.get_aligned_dataset_indices(i),
):
matrix_container_temp = self._matrix_containers[label]
if matrix_container_temp.is_index_dependent:
matrix_containers.append(
MatrixContainer(
clp_labels=matrix_container_temp.clp_labels,
matrix=matrix_container_temp.matrix[index],
)
)
],
[
self.group.dataset_models[label].scale # type:ignore[misc]
if self.group.dataset_models[label].scale is not None
else 1
for label in self._data_provider.group_definitions[group_label]
],
else:
matrix_containers.append(matrix_container_temp)

matrix_scales = [
self.group.dataset_models[label].scale
if self.group.dataset_models[label].scale is not None
else 1
for label in self._data_provider.group_definitions[group_label]
]

group_matrix = self.align_matrices(
matrix_containers, matrix_scales # type:ignore[arg-type]
)

self._aligned_full_clp_labels[i] = full_clp_labels[group_label]
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:
group_matrix = group_matrix.create_weighted_matrix(weight)
group_matrix_single = group_matrix_single.create_weighted_matrix(weight)

self._aligned_matrices[i] = group_matrix
self._aligned_matrices[i] = group_matrix_single

def align_full_clp_labels(self) -> dict[str, list[str]]:
"""Align the unreduced clp labels.
Expand Down