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

🐛 Crash in optimization_group_calculator_linked when using guidance spectra #950

Closed
jsnel opened this issue Jan 4, 2022 · 0 comments · Fixed by #948
Closed

🐛 Crash in optimization_group_calculator_linked when using guidance spectra #950

jsnel opened this issue Jan 4, 2022 · 0 comments · Fixed by #948
Labels
Type: Bug Minor issues, non-crashing bug, slowdowns

Comments

@jsnel
Copy link
Member

jsnel commented Jan 4, 2022

Version information

  • pyglotaran version: main

Describe the bug

The code

   dataset["matrix"] = (
                (
                    (self._model_dimension),
                    ("clp_label"),
                ),
                self._group.matrices[label].matrix,
            )

doesn't work for an analysis with multiple dataset, including some guidance spectra (it crashes on creating the result for the first guidance spectra) because self._group.matrices then returns a list of CalculatedMatrix objects, instead of a single CalculatedMatrix object.

A fix would be

 dataset["matrix"] = (
                (
                    (self._global_dimension),
                    (self._model_dimension),
                    ("clp_label"),
                ),
                np.asarray([m.matrix for m in self._group.matrices[label]]),
            )

but only in the case where the result is a list of CalcualtedMatrix objects.

To Reproduce

Run the Artificial Lego example.

Expected behavior

No crashes, while also not failing for all existing examples and unit tests.

Possible fix

Testing what the type is and excuting case dependent code.

 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]]),
            )
@jsnel jsnel added the Type: Bug Minor issues, non-crashing bug, slowdowns label Jan 4, 2022
jsnel added a commit to jsnel/pyglotaran that referenced this issue Jan 4, 2022
- 🩹 Fix Crash in optimization_group_calculator_linked when using guidance spectra Type: Bug (glotaran#950)

Closes: glotaran#950
jsnel added a commit to jsnel/pyglotaran that referenced this issue Jan 5, 2022
- 🩹 Fix Crash in optimization_group_calculator_linked when using guidance spectra Type: Bug (glotaran#950)

Closes: glotaran#950
jsnel added a commit to jsnel/pyglotaran that referenced this issue Jan 5, 2022
@jsnel jsnel closed this as completed in #948 Jan 5, 2022
jsnel added a commit that referenced this issue Jan 5, 2022
* 🩹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 <>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Minor issues, non-crashing bug, slowdowns
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant