Skip to content

Commit

Permalink
🩹Fix bug in create_index_independent_result_dataset (#948)
Browse files Browse the repository at this point in the history
* 🩹Fix bug in create_index_independent_result_dataset

- Indexing did not match content of _group.matrices (list of CalculatedMatrix objects)
- Dimension did not match (for guidance spectra) (global_dimension_index appeared to be missing

* 'Refactored by Sourcery'

* 👌Make setting dataset["matrix"] type(self._group.matrices) dependent

- 🩹 Fix Crash in optimization_group_calculator_linked when using guidance spectra Type: Bug (#950)

Closes: #950

* 📚 Add change to changelog

This PR closes #950

Co-authored-by: Sourcery AI <>
  • Loading branch information
jsnel authored Jan 5, 2022
1 parent b1f678a commit 91930ae
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

### 🩹 Bug fixes

- 🩹 Fix Crash in optimization_group_calculator_linked when using guidance spectra (#950)

### 📚 Documentation

### 🗑️ Deprecations (due in 0.8.0)
Expand Down
27 changes: 19 additions & 8 deletions glotaran/analysis/optimization_group_calculator_linked.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ def _apply_scale(self, group_model: DatasetIndexModelGroup, matrix: np.ndarray):
for i, index_model in enumerate(group_model.dataset_models):
label = index_model.label
if self._group.dataset_models[label] is not None:
start = sum(group_model.data_sizes[0:i])
start = sum(group_model.data_sizes[:i])
end = start + group_model.data_sizes[i]
matrix[start:end, :] *= self._group.dataset_models[label].scale

Expand Down Expand Up @@ -461,13 +461,24 @@ def create_index_independent_result_dataset(
) -> xr.Dataset:
"""Creates a result datasets for index independent matrices."""

dataset["matrix"] = (
(
(self._model_dimension),
("clp_label"),
),
self._group.matrices[label].matrix,
)
dummy = self._group.matrices[label]
if isinstance(dummy, CalculatedMatrix):
dataset["matrix"] = (
(
(self._model_dimension),
("clp_label"),
),
self._group.matrices[label].matrix,
)
else:
dataset["matrix"] = (
(
(self._global_dimension),
(self._model_dimension),
("clp_label"),
),
np.asarray([m.matrix for m in self._group.matrices[label]]),
)
dataset["clp"] = self._group.clps[label]

for index, grouped_problem in enumerate(self.bag):
Expand Down

0 comments on commit 91930ae

Please sign in to comment.