Skip to content

Conversation

jhaigh0
Copy link
Contributor

@jhaigh0 jhaigh0 commented Sep 17, 2024

Description of work

Fix crash in the case of plotting data with negative errors.

Instead, print a warning and plot without errors.

Fixes #37973

To test:

  • Load this data with negative errors
    BCA299_Subt_QLd_Result.zip

  • Plot Spectra with errors 6-8

  • Should see a warning printed but plot opens normally.


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.

@jhaigh0 jhaigh0 added Bug Issues and pull requests that are regressions or would be considered a bug by users (e.g. crashing) ISIS: Core Issue and pull requests at ISIS that relate to Core features and functions labels Sep 17, 2024
@jhaigh0 jhaigh0 added this to the Release 6.11 milestone Sep 17, 2024
@jhaigh0 jhaigh0 changed the base branch from main to release-next September 17, 2024 12:16
@jhaigh0 jhaigh0 changed the title 37973 warning for negative errors Fix plot crash on negative errors Sep 17, 2024
Copy link
Collaborator

@Despiix Despiix left a comment

Choose a reason for hiding this comment

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

Nevermind all good

Despiix
Despiix previously approved these changes Sep 26, 2024
Copy link
Collaborator

@Despiix Despiix left a comment

Choose a reason for hiding this comment

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

Tested according to test instructions and read the code. Works well.

@rbauststfc rbauststfc self-assigned this Sep 26, 2024
@rbauststfc
Copy link
Contributor

Sorry, a quick question before merging this one in - the linked issue has a comment in the description: "Need a second opinion on this: Do we then attempt to plot the data but taking the absolute positive value of the errors?". This PR has gone with the option to plot the absolute positive value of the errors, and I was just wondering how we came to that final decision?

@jhaigh0
Copy link
Contributor Author

jhaigh0 commented Sep 26, 2024

Sorry, a quick question before merging this one in - the linked issue has a comment in the description: "Need a second opinion on this: Do we then attempt to plot the data but taking the absolute positive value of the errors?". This PR has gone with the option to plot the absolute positive value of the errors, and I was just wondering how we came to that final decision?

I was thinking, a) this is a very rare scenario and b) there is not currently a good mechanism for 'rejecting' a plot; not try catch around the complicated plotting process etc. I thought, since this is a very unlikely problem, the simple option rather than the complex one was better.

@rbauststfc
Copy link
Contributor

Thanks for the explanation @jhaigh0, can definitely see where you're coming from, particularly if it's complicated to reject plotting altogether!

Although this is a rare scenario, what concerns me slightly is if a user could quite easily miss the warning message in the messages pane and then could end up slightly misled about their error values because converting them to positive makes them look like valid errors. I've had a quick chat with Richard to try and get a science perspective on this and his opinion was that if the error is negative then it's garbage and should probably be set to null value (which may be 0 or NaN). We're not sure what happens to NaN values when plotting (perhaps ignored so may look like 0 anyway?), but either way Richard felt that plotting the absolute value of a garbage number was more misleading. What do you think?

@RichardWaiteSTFC
Copy link
Contributor

Further to the above, it is possible that taking the abs of the error gives you the correct result by chance - for example maybe there's a missing abs in the error propagation when the workspace is produced - but in my opinion would this would be 'fixing' the bug in the wrong place and as @rbauststfc says potentially makes it difficult for the user to see something is wrong.

@jhaigh0
Copy link
Contributor Author

jhaigh0 commented Sep 27, 2024

okay understood, I will try to change it to plot without errors + a warning in this case.

Copy link
Collaborator

@Despiix Despiix left a comment

Choose a reason for hiding this comment

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

Following the discussion above, I tested based on the coding instructions and it works well. The updated code does not take the the abs of the error anymore.

@rbauststfc
Copy link
Contributor

Thanks @jhaigh0 and @Despiix for taking the time to have a further look at this one. The solution is looking really good to me - I'll get this merged in!

@rbauststfc rbauststfc merged commit 7f66679 into release-next Sep 30, 2024
10 checks passed
@rbauststfc rbauststfc deleted the 37973_warning_for_negative_errors branch September 30, 2024 14:17
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) ISIS: Core Issue and pull requests at ISIS that relate to Core features and functions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash when plotting Quasi result data with errors
4 participants