Commit e53515f3 authored by Gagik Vardanyan's avatar Gagik Vardanyan
Browse files

Catch the error in processGroups

parent 2e5e37f9
...@@ -1429,7 +1429,20 @@ bool Algorithm::processGroups() { ...@@ -1429,7 +1429,20 @@ bool Algorithm::processGroups() {
// Either: this is the single group // Either: this is the single group
// OR: all inputs are groups // OR: all inputs are groups
// ... so get then entry^th workspace in this group // ... so get then entry^th workspace in this group
ws = thisGroup[entry]; if (entry < thisGroup.size()) {
ws = thisGroup[entry];
} else {
// This can happen when one has more than one input group
// workspaces, having different sizes. For example one workspace
// group is the corrections which has N parts (e.g. weights for polarized measurement)
// while the other one is the actual input workspace group, where each item needs to be
// corrected together with all N inputs of the second group. In this
// case processGroup needs to be overridden, which is currently not
// possible in python.
throw std::runtime_error(
"Unable to process over groups; consider passing workspaces "
"one-by-one or override processGroup method of the algorithm.");
}
} }
// Append the names together // Append the names together
if (!outputBaseName.empty()) if (!outputBaseName.empty())
......
...@@ -64,6 +64,7 @@ class ApplyPaalmanPingsCorrection(PythonAlgorithm): ...@@ -64,6 +64,7 @@ class ApplyPaalmanPingsCorrection(PythonAlgorithm):
# pylint: disable=too-many-branches # pylint: disable=too-many-branches
def PyExec(self): def PyExec(self):
self._setup()
if not self._use_corrections: if not self._use_corrections:
logger.information('Not using corrections') logger.information('Not using corrections')
if not self._use_can: if not self._use_can:
...@@ -156,6 +157,8 @@ class ApplyPaalmanPingsCorrection(PythonAlgorithm): ...@@ -156,6 +157,8 @@ class ApplyPaalmanPingsCorrection(PythonAlgorithm):
if sample_unit != 'Label': if sample_unit != 'Label':
output_workspace = self._convert_units(output_workspace, sample_unit, emode, efixed) output_workspace = self._convert_units(output_workspace, sample_unit, emode, efixed)
if output_workspace.name():
RenameWorkspace(InputWorkspace=output_workspace, OutputWorkspace=self.getPropertyValue('OutputWorkspace'))
self.setProperty('OutputWorkspace', output_workspace) self.setProperty('OutputWorkspace', output_workspace)
prog_wrkflow.report('Algorithm Complete') prog_wrkflow.report('Algorithm Complete')
...@@ -190,17 +193,12 @@ class ApplyPaalmanPingsCorrection(PythonAlgorithm): ...@@ -190,17 +193,12 @@ class ApplyPaalmanPingsCorrection(PythonAlgorithm):
if corrections_issues: if corrections_issues:
issues['CorrectionsWorkspace'] = "\n".join(corrections_issues) issues['CorrectionsWorkspace'] = "\n".join(corrections_issues)
if isinstance(self._sample_workspace, MatrixWorkspace):
if isinstance(self._sample_workspace, WorkspaceGroup):
issues['SampleWorkspace'] = 'WorkspaceGroups are not supported'
elif isinstance(self._sample_workspace, MatrixWorkspace):
sample_unit_id = self._sample_workspace.getAxis(0).getUnit().unitID() sample_unit_id = self._sample_workspace.getAxis(0).getUnit().unitID()
# Check sample and container X axis units match # Check sample and container X axis units match
if self._use_can: if self._use_can:
if isinstance(self._container_workspace, WorkspaceGroup): if isinstance(self._container_workspace, MatrixWorkspace):
issues['CanWorkspace'] = 'WorkspaceGroups are not supported'
elif isinstance(self._container_workspace, MatrixWorkspace):
can_unit_id = self._container_workspace.getAxis(0).getUnit().unitID() can_unit_id = self._container_workspace.getAxis(0).getUnit().unitID()
if can_unit_id != sample_unit_id: if can_unit_id != sample_unit_id:
issues['CanWorkspace'] = 'X axis unit must match SampleWorkspace' issues['CanWorkspace'] = 'X axis unit must match SampleWorkspace'
...@@ -357,7 +355,9 @@ class ApplyPaalmanPingsCorrection(PythonAlgorithm): ...@@ -357,7 +355,9 @@ class ApplyPaalmanPingsCorrection(PythonAlgorithm):
Correct for sample only (when no container is given). Correct for sample only (when no container is given).
""" """
logger.information('Correcting sample') logger.information('Correcting sample')
return sample_workspace / self._convert_units_wavelength(a_ss_workspace) correction_in_lambda = self._convert_units_wavelength(a_ss_workspace)
corrected = Divide(LHSWorkspace=sample_workspace, RHSWorkspace=correction_in_lambda)
return corrected
def _correct_sample_can(self, sample_workspace, container_workspace, factor_workspaces): def _correct_sample_can(self, sample_workspace, container_workspace, factor_workspaces):
""" """
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment