Skip to content

Commit

Permalink
Move isGroup to isinstance( WorkspaceGroup)
Browse files Browse the repository at this point in the history
  • Loading branch information
gesnerpassos committed Mar 5, 2013
1 parent 0707ad2 commit 0b1b541
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
15 changes: 11 additions & 4 deletions Code/Mantid/scripts/SANS/ISISCommandInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
import isis_reducer
from centre_finder import CentreFinder as CentreFinder
#import SANSReduction
import mantid
from mantid.simpleapi import *
from mantid.api import WorkspaceGroup
import copy
from SANSadd2 import *

Expand Down Expand Up @@ -884,7 +885,7 @@ def PlotResult(workspace, canvas=None):
"""
#ensure that we are dealing with a workspace handle rather than its name
workspace = mtd[str(workspace)]
if workspace.isGroup():
if isinstance(workspace, WorkspaceGroup):
numSpecs = workspace[0].getNumberHistograms()
else:
numSpecs = workspace.getNumberHistograms()
Expand Down Expand Up @@ -1106,5 +1107,11 @@ def FindBeamCentre(rlow, rupp, MaxIter = 10, xstart = None, ystart = None):

_refresh_singleton()

#if __name__ != '__main__':
# AssignSample('c:\\mantid\\test\\data\\SANS2D\\SANS2D000992.raw')
if __name__ == '__main__':
SetVerboseMode(True)
SANS2D()
MaskFile('/apps/mantid/systemtests/Data/SANS2D/MASKSANS2D_123T_4m_Xpress_8mm.txt')
Set1D()
AssignSample('/apps/mantid/systemtests/Data/SANS2D/SANS2D00002500.nxs')
Gravity(True)

4 changes: 3 additions & 1 deletion Code/Mantid/scripts/SANS/isis_instrument.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from reduction import instrument
import math
from mantid.simpleapi import *
from mantid.api import WorkspaceGroup

import sys

class DetectorBank:
Expand Down Expand Up @@ -807,7 +809,7 @@ def get_detector_log(self, wksp):
"""
self._marked_dets = []
#assume complete log information is stored in the first entry, it isn't stored in the group workspace itself
if wksp.isGroup():
if isinstance(wksp, WorkspaceGroup):
wksp = wksp[0]

samp = wksp.getRun()
Expand Down
15 changes: 8 additions & 7 deletions Code/Mantid/scripts/SANS/isis_reduction_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import isis_reducer
import reduction.instruments.sans.sans_reduction_steps as sans_reduction_steps
from mantid.simpleapi import *
from mantid.api import WorkspaceGroup
import SANSUtility
import isis_instrument
import os
Expand Down Expand Up @@ -203,8 +204,8 @@ def _assignHelper(self, reducer):
return logs

def _leaveSinglePeriod(self, workspace, period):
groupW = mantid[workspace]
if groupW.isGroup():
groupW = mtd[workspace]
if isinstance(groupW, WorkspaceGroup):
num_periods = groupW.getNames()
else:
num_periods = 1
Expand Down Expand Up @@ -293,8 +294,8 @@ def _find_workspace_num_periods(self, workspace):
@param workspace: the name of the workspace
"""
numPeriods = -1
pWorksp = mantid[workspace]
if pWorksp.isGroup() :
pWorksp = mtd[workspace]
if isinstance(pWorksp, WorkspaceGroup) :
#get the number of periods in a group using the fact that each period has a different name
numPeriods = len(pWorksp.getNames())
else :
Expand Down Expand Up @@ -995,9 +996,9 @@ def execute(self, reducer, workspace):
if self.wksp_name == '':
raise RuntimeError('Unable to load SANS sample run, cannot continue.')

p_run_ws = mantid[self.wksp_name]
p_run_ws = mtd[self.wksp_name]

if p_run_ws.isGroup():
if isinstance(p_run_ws, WorkspaceGroup):
p_run_ws = p_run_ws[0]

try:
Expand Down Expand Up @@ -1404,7 +1405,7 @@ def execute(self, reducer, workspace):
rescaleToColette = math.pi
scalefactor /= rescaleToColette

ws = mantid[workspace]
ws = mtd[workspace]
ws *= scalefactor

class CalculateNormISIS(sans_reduction_steps.CalculateNorm):
Expand Down

0 comments on commit 0b1b541

Please sign in to comment.