-
Notifications
You must be signed in to change notification settings - Fork 122
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
Added validation for event workspaces in ConjoinWorkspaces #20006
Conversation
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 just want answers to my comments. The python script works as expected.
@@ -55,6 +55,8 @@ void ConjoinWorkspaces::exec() { | |||
} | |||
|
|||
if (event_ws1 && event_ws2) { | |||
this->validateInputs(*event_ws1, *event_ws2); | |||
|
|||
// We do not need to check that binning is compatible, just that there is no | |||
// overlap | |||
// make sure we should bother checking |
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.
Is this comment still correct?
// Delete the second input workspace from the ADS | ||
AnalysisDataService::Instance().remove(getPropertyValue("InputWorkspace2")); | ||
// Set the result workspace to the first input | ||
setProperty("InputWorkspace1", output); | ||
} |
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.
Have you done anything besides replace (if { code, return } more_code) with if {code} else {more_code} ?
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 see you added this->validateInputs(*event_ws1, *event_ws2);
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 haven't put names to all the new faces yet. So if you want to talk to me about this, please do so.
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'm happy with this.
The RHEL7 system test has picked up a failure in |
It was explicitly stated in the code that the binning doesn't matter for events so I think we need to skip matching those and just test everything else. |
…ct/mantid into 5564_validate_inputs_conjoin
"Both input workspaces must have common binning for all their spectra"); | ||
throw std::invalid_argument( | ||
"Both input workspaces must have common binning for all their spectra"); | ||
// Workspaces with point data are allowed to have different binning |
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'm not this is exactly what we want here. Point data and event workspaces are different things. EventWorkspace
is a special type of MatrixWorkspace
that stores collections of signal/timestamp pairs per spectrum. Histograms of these collections are then generated on the fly from a current set of bin boundaries. Here the check is unimportant because of this on-the-fly generation.
For the MatrixWorkspace
case, regarless of point or histogram status, the algorithm appends the spectra from the rhs to the lfs workspace but uses the X values exclusively from the lhs. If they are not the same in both cases then the numbers at the end could be misleading.
Perhaps the easiest way to solve this is to add a flag to validateInputs
to disable the bin checking and then set this to true
on line 58 of ConjoinWorkspaces.cpp
as we already have checked for event vs non-event here?
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.
Good, we're almost there. I think there is just one small tidy up remaining.
@@ -56,6 +56,8 @@ class DLLExport WorkspaceJoiners : public API::Algorithm { | |||
|
|||
using Mantid::API::Algorithm::validateInputs; | |||
void validateInputs(const API::MatrixWorkspace &ws1, |
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.
We can collapse these into a single method with a default parameter:
void validateInputs(const API::MatrixWorkspace &ws1, const API::MatrixWorkspace &ws2, const bool checkBinning=true);
rather than needing two methods.
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.
Thanks, @josephframsay. This looks good now.
Validate EventWorkspaces according to their bins
To test:
Running the above script in Mantid should produce a ValueError, where previously there was an unhandled exception.
Fixes #5564 .
Release Notes
Does not need to be in the release notes.
Reviewer
Please comment on the following (full description):
Code Review
Functional Tests
Does everything look good? Mark the review as Approve. A member of
@mantidproject/gatekeepers
will take care of it.