Skip to content
Snippets Groups Projects
Commit fde3e5fe authored by Harriet Brown's avatar Harriet Brown
Browse files

Make changes from code review

This commit makes changes requested from review. It removes a validator function that is covered by the ADSValidator in the input parameter. It also changes the if statement from type() == to an isinstance() to check for inheritance.

Re #27445
parent 3b9bcfa1
No related merge requests found
......@@ -39,14 +39,12 @@ class MatchAndMergeWorkspaces(DataProcessorAlgorithm):
# and must be public of ExperimentInfo
issues = dict()
ws_list = self.getProperty('InputWorkspaces').value
if not self.validate_ws(ws_list):
issues['InputWorkspaces'] = 'InputWorkspaces is not a list of workspaces or group workspace'
spectra_count = 0
for name_in_list in ws_list:
ws_in_list = AnalysisDataService.retrieve(name_in_list)
if type(ws_in_list) == Workspace2D:
if isinstance(ws_in_list, Workspace2D):
spectra_count += ws_in_list.getNumberHistograms()
if type(ws_in_list) == WorkspaceGroup:
if isinstance(ws_in_list, WorkspaceGroup):
for ws_in_group in ws_in_list:
spectra_count += ws_in_group.getNumberHistograms()
......@@ -60,15 +58,6 @@ class MatchAndMergeWorkspaces(DataProcessorAlgorithm):
return issues
@staticmethod
def validate_ws(ws_in):
for ws in ws_in:
try:
AnalysisDataService.retrieve(ws)
except KeyError:
return False
return True
def PyInit(self):
self.declareProperty(StringArrayProperty('InputWorkspaces', direction=Direction.Input, validator=ADSValidator()),
doc='List of workspaces or group workspace containing workspaces to be merged.')
......@@ -118,9 +107,9 @@ class MatchAndMergeWorkspaces(DataProcessorAlgorithm):
output = []
for name_in_list in inputs:
ws_in_list = AnalysisDataService.retrieve(name_in_list)
if type(ws_in_list) == Workspace2D:
if isinstance(ws_in_list, Workspace2D):
output.append(ws_in_list)
if type(ws_in_list) == WorkspaceGroup:
if isinstance(ws_in_list, WorkspaceGroup):
for ws_in_group in ws_in_list:
output.append(ws_in_group)
return output
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment