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

32679 fixed FindPeaks crash when the number of bins are not sufficient #37263

Merged
merged 6 commits into from
May 10, 2024

Conversation

warunawickramasingha
Copy link
Contributor

Description of work

Fixed a crash on FindPeaks algorithm when run on histograms containing a single bin by raising an error message on this condition.

Fixes #32679.

Further detail of work

To test:

  1. Run the below code and the algorithm should not crash instead should throw a meaningful error
# import mantid algorithms, numpy and matplotlib
from mantid.simpleapi import *
import matplotlib.pyplot as plt
import numpy as np

ws = CreateWorkspace(OutputWorkspace='test', DataX='1', DataY='0,0,0,2,5,2,0,0,0,0', NSpec=10)

peaks_ws = FindPeaks(ws)
  1. Errors should be raised even when the FindPeaks algorithm is run from Algorithms window on a similar workspace without crashing the workbench.

Reviewer

Please comment on the points listed below (full description).
Your comments will be used as part of the gatekeeper process, so please comment clearly on what you have checked during your review. If changes are made to the PR during the review process then your final comment will be the most important for gatekeepers. In this comment you should make it clear why any earlier review is still valid, or confirm that all requested changes have been addressed.

Code Review

  • Is the code of an acceptable quality?
  • Does the code conform to the coding standards?
  • Are the unit tests small and test the class in isolation?
  • If there is GUI work does it follow the GUI standards?
  • If there are changes in the release notes then do they describe the changes appropriately?
  • Do the release notes conform to the release notes guide?

Functional Tests

  • Do changes function as described? Add comments below that describe the tests performed?
  • Do the changes handle unexpected situations, e.g. bad input?
  • Has the relevant (user and developer) documentation been added/updated?

Does everything look good? Mark the review as Approve. A member of @mantidproject/gatekeepers will take care of it.

Gatekeeper

If you need to request changes to a PR then please add a comment and set the review status to "Request changes". This will stop the PR from showing up in the list for other gatekeepers.

@sf1919 sf1919 added this to the Release 6.10 milestone May 7, 2024
@warunawickramasingha warunawickramasingha added Bug Issues and pull requests that are regressions or would be considered a bug by users (e.g. crashing) Diffraction Issues and pull requests related to diffraction ISIS Team: Diffraction Issue and pull requests managed by the Diffraction subteam at ISIS labels May 7, 2024
sf1919
sf1919 previously requested changes May 7, 2024
Copy link
Contributor

@sf1919 sf1919 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please can you check whether the following warnings apply to this PR? The others I think are being fixed elsewhere

GNU C Compiler (Linux)

Clang Warnings (OSX)

@sf1919 sf1919 dismissed their stale review May 10, 2024 10:11

The warnings have been resolved and therefore the specific changes requested have been dealt with. PR still needs reviewing in full though

Copy link
Contributor

@RichardWaiteSTFC RichardWaiteSTFC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix and thanks for adding a test. It would be good to have this check done in the validation but there is no input validation run before the exec in this algorithm and it doesn't seem worth it just for this fix. Just a minor thing then good to approve!

if (!m_dataWS->isRaggedWorkspace() && (m_dataWS->blocksize() <= static_cast<size_t>(w))) {
std::stringstream errss;
errss << "Block size of the workspace should be greater than:" << w;
g_log.warning(errss.str());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not necessary to print a warning as well as throw an error with the same message - it prints this

Block size of the workspace should be greater than:601
Error in execution of algorithm FindPeaks:
Block size of the workspace should be greater than:601

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for noting that! Did the changes as requested.

Copy link
Contributor

@RichardWaiteSTFC RichardWaiteSTFC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the change looks good!

@jhaigh0 jhaigh0 changed the base branch from main to release-next May 10, 2024 12:52
@jhaigh0 jhaigh0 dismissed RichardWaiteSTFC’s stale review May 10, 2024 12:52

The base branch was changed.

@robertapplin robertapplin merged commit b837b6b into release-next May 10, 2024
10 checks passed
@robertapplin robertapplin deleted the 32679_Findpeaks_crash_single_bin branch May 10, 2024 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Issues and pull requests that are regressions or would be considered a bug by users (e.g. crashing) Diffraction Issues and pull requests related to diffraction ISIS Team: Diffraction Issue and pull requests managed by the Diffraction subteam at ISIS
Projects
Status: Waiting response
Status: Done
Development

Successfully merging this pull request may close these issues.

FindPeaks crashes if run on histograms containing a single bin
4 participants