-
Notifications
You must be signed in to change notification settings - Fork 128
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
Add check for groups in SaveNXcanSAS #38892
base: main
Are you sure you want to change the base?
Conversation
…sGroups for workspaces other than input
@@ -24,6 +24,16 @@ void SaveNXcanSAS::init() { initStandardProperties(); } | |||
|
|||
std::map<std::string, std::string> SaveNXcanSAS::validateInputs() { return validateStandardInputs(); } | |||
|
|||
bool SaveNXcanSAS::checkGroups() { | |||
Mantid::API::Workspace_sptr &&workspace = getProperty("InputWorkspace"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we gain anything by making this an r-value reference. If getProperty("InputWorkspace");
returns an r-value then Mantid::API::Workspace_sptr workspace = getProperty("InputWorkspace");
will use the move constructor to avoid a copy, which is efficient enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may be even better to do const Mantid::API::Workspace_sptr &workspace = getProperty("InputWorkspace");
, as the isGroup
method is marked const. This will work as you can assign r-values to const l value references.
try { | ||
if (workspace && workspace->isGroup()) | ||
return true; | ||
} catch (...) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we be less general here, is there a specific error type you are expecting during isGroup
?
We've recently added the capability to input groups in SaveNXcanSAS algorithm #38504.
The algorithm class checks for group workspaces in the input property and if so, it launches a different method to process the groups (processGroups). That method was overridden in order to handle input workspace groups separately in #38504.
Additionally, if any of the workspace property is a group, processGroup method will be called back. In the case of SaveNXcanSAS, it is also possible to input a transmission workspace and tranmission can workspace properties as groups, this was causing a crash when trying to input these properties as groups, as the processGroup method is called when it shouldn't.
To fix this, I have also overriden the checkGroups method from the base algorithm class to specify that processGroups shall only be called when the input workspace property is a group.
There is no associated issue.
Further detail of work
This is an edge case, as the workspace property validator that checks for workspace with given units (in this case wavelength) seems to be selecting also the workspace group name if all the workspace members of a group have the correct unit. Not sure if this an intended behaviour of the workspace property or a bug, but it may merit a separate investigation.
To test:
This does not require release notes because is a regression.
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
Functional Tests
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.