From fde3e5fef1f40b8a5eccd4abd2470b5b267f3379 Mon Sep 17 00:00:00 2001
From: Harriet Brown <harriet.brown@stfc.ac.uk>
Date: Tue, 17 Dec 2019 15:57:24 +0000
Subject: [PATCH] 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
---
 .../MatchAndMergeWorkspaces.py                | 19 ++++---------------
 1 file changed, 4 insertions(+), 15 deletions(-)

diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/MatchAndMergeWorkspaces.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/MatchAndMergeWorkspaces.py
index 2560619a0bf..0bb57638599 100644
--- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/MatchAndMergeWorkspaces.py
+++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/MatchAndMergeWorkspaces.py
@@ -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
-- 
GitLab