Skip to content

Commit

Permalink
A few more warnings. Refs #11824
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreiSavici committed May 28, 2015
1 parent 06eaa4f commit c50f149
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 35 deletions.
18 changes: 9 additions & 9 deletions Code/Mantid/Framework/PythonInterface/mantid/simpleapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def Load(*args, **kwargs):
if key not in algm:
logger.warning("You've passed a property (%s) to Load() that doesn't apply to this file type." % key)
del final_keywords[key]
_set_properties(algm, **final_keywords)
set_properties(algm, **final_keywords)
algm.execute()

# If a WorkspaceGroup was loaded then there will be a set of properties that have an underscore in the name
Expand Down Expand Up @@ -165,7 +165,7 @@ def LoadDialog(*args, **kwargs):
if 'Message' not in arguments: arguments['Message']=''

algm = _create_algorithm_object('Load')
_set_properties_dialog(algm,**arguments)
set_properties_dialog(algm,**arguments)
algm.execute()
return algm

Expand Down Expand Up @@ -213,7 +213,7 @@ def Fit(*args, **kwargs):
if key not in algm:
logger.warning("You've passed a property (%s) to Fit() that doesn't apply to any of the input workspaces." % key)
del kwargs[key]
_set_properties(algm, **kwargs)
set_properties(algm, **kwargs)
algm.execute()

return _gather_returns('Fit', lhs, algm)
Expand Down Expand Up @@ -252,7 +252,7 @@ def FitDialog(*args, **kwargs):
if 'Message' not in arguments: arguments['Message']=''

algm = _create_algorithm_object('Fit')
_set_properties_dialog(algm,**arguments)
set_properties_dialog(algm,**arguments)
algm.execute()
return algm

Expand Down Expand Up @@ -348,7 +348,7 @@ def CutMD(*args, **kwargs):

#Run the algorithm across the inputs and outputs
for i in range(len(to_process)):
_set_properties(algm, **kwargs)
set_properties(algm, **kwargs)
algm.setProperty('InputWorkspace', to_process[i])
algm.setProperty('OutputWorkspace', out_names[i])
algm.execute()
Expand Down Expand Up @@ -620,7 +620,7 @@ def _set_logging_option(algm_obj, kwargs):
algm_obj.setLogging(kwargs[__LOGGING_KEYWORD__])
del kwargs[__LOGGING_KEYWORD__]

def _set_properties(alg_object, *args, **kwargs):
def set_properties(alg_object, *args, **kwargs):
"""
Set all of the properties of the algorithm
:param alg_object: An initialised algorithm object
Expand Down Expand Up @@ -692,7 +692,7 @@ def algorithm_wrapper(*args, **kwargs):
lhs_args = _get_args_from_lhs(lhs, algm)
final_keywords = _merge_keywords_with_lhs(kwargs, lhs_args)

_set_properties(algm, *args, **final_keywords)
set_properties(algm, *args, **final_keywords)
algm.execute()
return _gather_returns(algorithm, lhs, algm)

Expand Down Expand Up @@ -812,7 +812,7 @@ def get_self(frame):

#-------------------------------------------------------------------------------------------------------------

def _set_properties_dialog(algm_object, *args, **kwargs):
def set_properties_dialog(algm_object, *args, **kwargs):
"""
Set the properties all in one go assuming that you are preparing for a
dialog box call. If the dialog is cancelled raise a runtime error, otherwise
Expand Down Expand Up @@ -892,7 +892,7 @@ def algorithm_wrapper(*args, **kwargs):
kwargs[item] = ""

algm = _create_algorithm_object(algorithm, _version)
_set_properties_dialog(algm, *args, **kwargs) # throws if input cancelled
set_properties_dialog(algm, *args, **kwargs) # throws if input cancelled
algm.execute()
return algm

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ def category(self):
return 'Utility;PythonAlgorithms'

def summary(self):
return "Given a range of run numbers and an output workspace name, will compile a table of info for each run of the instrument you have set as default."
return "Given a range of run numbers and an output workspace name, will compile a table of info for "+\
"each run of the instrument you have set as default."

def PyInit(self):
# Declare algorithm properties.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
HAVE_MPI = False
mpiRank = 0 # simplify if clauses

COMPRESS_TOL_TOF = .01

EVENT_WORKSPACE_ID = "EventWorkspace"

#pylint: disable=too-many-instance-attributes
class SNSPowderReduction(DataProcessorAlgorithm):

COMPRESS_TOL_TOF = .01
_resampleX = None
_binning = None
_bin_in_dspace = None
Expand Down Expand Up @@ -145,7 +145,7 @@ def PyInit(self):

return


#pylint: disable=too-many-locals,too-many-branches,too-many-statements
def PyExec(self):
""" Main execution body
"""
Expand Down Expand Up @@ -203,9 +203,9 @@ def PyExec(self):
self._normalisebycurrent = self.getProperty("NormalizeByCurrent").value

# Tolerance for compress TOF event
COMPRESS_TOL_TOF = float(self.getProperty("CompressTOFTolerance").value)
if COMPRESS_TOL_TOF < 0.:
COMPRESS_TOL_TOF = 0.01
self.COMPRESS_TOL_TOF = float(self.getProperty("CompressTOFTolerance").value)
if self.COMPRESS_TOL_TOF < 0.:
self.COMPRESS_TOL_TOF = 0.01

# Process data
workspacelist = [] # all data workspaces that will be converted to d-spacing in the end
Expand Down Expand Up @@ -264,7 +264,7 @@ def PyExec(self):
samRun = api.Plus(LHSWorkspace=samRun, RHSWorkspace=temp, OutputWorkspace=samRun)
if samRun.id() == EVENT_WORKSPACE_ID:
samRun = api.CompressEvents(InputWorkspace=samRun, OutputWorkspace=samRun,\
Tolerance=COMPRESS_TOL_TOF) # 10ns
Tolerance=self.COMPRESS_TOL_TOF) # 10ns
api.DeleteWorkspace(str(temp))
# ENDIF
# ENDFOR (processing each)
Expand Down Expand Up @@ -388,7 +388,7 @@ def PyExec(self):
# compress events
if vanRun.id() == EVENT_WORKSPACE_ID:
vanRun = api.CompressEvents(InputWorkspace=vanRun, OutputWorkspace=vanRun,
Tolerance=COMPRESS_TOL_TOF) # 10ns
Tolerance=self.COMPRESS_TOL_TOF) # 10ns

# do the absorption correction
vanRun = api.ConvertUnits(InputWorkspace=vanRun, OutputWorkspace=vanRun, Target="TOF")
Expand All @@ -401,7 +401,7 @@ def PyExec(self):
DMin=self._info["d_min"], DMax=self._info["d_max"],
TMin=self._info["tof_min"], TMax=self._info["tof_max"],
RemovePromptPulseWidth=self._removePromptPulseWidth,
CompressTolerance=COMPRESS_TOL_TOF,
CompressTolerance=self.COMPRESS_TOL_TOF,
UnwrapRef=self._LRef, LowResRef=self._DIFCref,
LowResSpectrumOffset=self._lowResTOFoffset,
CropWavelengthMin=self._wavelengthMin, **(focuspos))
Expand Down Expand Up @@ -436,7 +436,7 @@ def PyExec(self):
samRun = api.Minus(LHSWorkspace=samRun, RHSWorkspace=canRun, OutputWorkspace=samRun)
if samRun.id() == EVENT_WORKSPACE_ID:
samRun = api.CompressEvents(InputWorkspace=samRun, OutputWorkspace=samRun,\
Tolerance=COMPRESS_TOL_TOF) # 10ns
Tolerance=self.COMPRESS_TOL_TOF) # 10ns
canRun = str(canRun)
if vanRun is not None:
samRun = api.Divide(LHSWorkspace=samRun, RHSWorkspace=vanRun, OutputWorkspace=samRun)
Expand All @@ -448,7 +448,7 @@ def PyExec(self):

if samRun.id() == EVENT_WORKSPACE_ID:
samRun = api.CompressEvents(InputWorkspace=samRun, OutputWorkspace=samRun,\
Tolerance=COMPRESS_TOL_TOF) # 5ns/
Tolerance=self.COMPRESS_TOL_TOF) # 5ns/

# make sure there are no negative values - gsas hates them
if self.getProperty("PushDataPositive").value != "None":
Expand Down Expand Up @@ -488,6 +488,7 @@ def _loadCharacterizations(self, filename):
self._focusPos['Polar'] = results[5]
self._focusPos['Azimuthal'] = results[6]

#pylint: disable=too-many-branches
def _loadData(self, runnumber, extension, filterWall=None, outname=None, **chunk):
if runnumber is None or runnumber <= 0:
return None
Expand Down Expand Up @@ -529,7 +530,7 @@ def _loadData(self, runnumber, extension, filterWall=None, outname=None, **chunk

# filter bad pulses
if self._filterBadPulses > 0.:
isEventWS = isinstance(wksp, mantid.api._api.IEventWorkspace)
isEventWS = isinstance(wksp, mantid.api.IEventWorkspace)
if isEventWS is True:
# Event workspace: record original number of events
numeventsbefore = wksp.getNumberEvents()
Expand Down Expand Up @@ -569,6 +570,7 @@ def __logChunkInfo(self, chunk):
keys = [ str(key) + "=" + str(chunk[key]) for key in keys ]
self.log().information("Working on chunk [" + ", ".join(keys) + "]")

#pylint: disable=too-many-arguments,too-many-locals,too-many-branches
def _focusChunks(self, runnumber, extension, filterWall, calib, splitwksp=None, preserveEvents=True):
""" Load, (optional) split and focus data in chunks
Expand Down Expand Up @@ -608,7 +610,7 @@ def _focusChunks(self, runnumber, extension, filterWall, calib, splitwksp=None,

firstChunkList = []
wksplist = []
for n in xrange(numwksp):
for dummy_n in xrange(numwksp):
# In some cases, there will be 1 more splitted workspace (unfiltered)
firstChunkList.append(True)
wksplist.append(None)
Expand Down Expand Up @@ -701,7 +703,7 @@ def _focusChunks(self, runnumber, extension, filterWall, calib, splitwksp=None,
Params=self._binning, ResampleX=self._resampleX, Dspacing=self._bin_in_dspace,\
DMin=self._info["d_min"], DMax=self._info["d_max"], TMin=self._info["tof_min"], TMax=self._info["tof_max"],\
PreserveEvents=preserveEvents,\
RemovePromptPulseWidth=self._removePromptPulseWidth, CompressTolerance=COMPRESS_TOL_TOF,\
RemovePromptPulseWidth=self._removePromptPulseWidth, CompressTolerance=self.COMPRESS_TOL_TOF,\
UnwrapRef=self._LRef, LowResRef=self._DIFCref, LowResSpectrumOffset=self._lowResTOFoffset,\
CropWavelengthMin=self._wavelengthMin, **(focuspos))
for iws in xrange(temp.getNumberHistograms()):
Expand Down Expand Up @@ -752,7 +754,7 @@ def _focusChunks(self, runnumber, extension, filterWall, calib, splitwksp=None,
for itemp in xrange(numwksp):
if wksplist[itemp].id() == EVENT_WORKSPACE_ID:
wksplist[itemp] = api.CompressEvents(InputWorkspace=wksplist[itemp],\
OutputWorkspace=wksplist[itemp], Tolerance=COMPRESS_TOL_TOF) # 100ns
OutputWorkspace=wksplist[itemp], Tolerance=self.COMPRESS_TOL_TOF) # 100ns

try:
if self._normalisebycurrent is True:
Expand All @@ -779,7 +781,7 @@ def _getinfo(self, wksp):
if mtd.doesExist("characterizations"):
# get the correct row of the table


#pylint: disable=unused-variable
charac = api.PDDetermineCharacterizations(InputWorkspace=wksp,
Characterizations="characterizations",
ReductionProperties="__snspowderreduction",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ def _calculate_resolution(self, workspace, output_ws_name):
fit = mantid.api.AlgorithmManager.createUnmanaged('Fit')
fit.initialize()
fit.setChild(True)
mantid.simpleapi._set_properties(fit, function, InputWorkspace=workspace, MaxIterations=0,
CreateOutput=True, Output=fit_naming_stem,
WorkspaceIndex=self._spectrum_index,
OutputCompositeMembers=True)
mantid.simpleapi.set_properties(fit, function, InputWorkspace=workspace, MaxIterations=0,
CreateOutput=True, Output=fit_naming_stem,
WorkspaceIndex=self._spectrum_index,
OutputCompositeMembers=True)
fit.execute()
fit_ws = fit.getProperty('OutputWorkspace').value

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,8 @@ def _save(self, worksspace_names):
DeleteWorkspace(Workspace=ws_name + '_aclimax_save_temp')

if 'davegrp' in self._save_formats:
ConvertSpectrumAxis(InputWorkspace=ws_name, OutputWorkspace=ws_name + '_davegrp_save_temp', Target='ElasticQ', EMode='Indirect')
ConvertSpectrumAxis(InputWorkspace=ws_name, OutputWorkspace=ws_name + '_davegrp_save_temp',
Target='ElasticQ', EMode='Indirect')
SaveDaveGrp(InputWorkspace=ws_name + '_davegrp_save_temp', Filename=ws_name + '.grp')
DeleteWorkspace(Workspace=ws_name + '_davegrp_save_temp')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import math
import sys

#pylint: disable=too-few-public-methods
class REFLOptions(object):
def __init__(self):
from reduction_gui.reduction.reflectometer.refl_data_script import DataSets as REFLDataSets
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ def _normalise(workspace):

return sample_mon_ws, empty_mon_ws, first_det, output_str, monitor_det_ID

#pylint: disable=too-many-arguments
def calculate_transmission(self, sample_mon_ws, empty_mon_ws, first_det,
trans_output_workspace, monitor_det_ID=None):
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import unittest
from mantid.simpleapi import CreateWorkspace, _set_properties
from mantid.simpleapi import CreateWorkspace, set_properties
from mantid.api import (MatrixWorkspaceProperty, AlgorithmFactory, AlgorithmManager,
DataProcessorAlgorithm, PythonAlgorithm)
from mantid.kernel import Direction
Expand Down Expand Up @@ -31,7 +31,7 @@ def PyExec(self):
alg.initialize()
args = {}
kwargs = {}
_set_properties(alg, *args, **kwargs)
set_properties(alg, *args, **kwargs)
alg.execute()

AlgorithmFactory.subscribe(ParentAlg)
Expand Down
4 changes: 2 additions & 2 deletions Code/Mantid/scripts/reduction/reducer.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def execute(self, reducer, inputworkspace=None, outputworkspace=None):
kwargs[kwargs["AlternateName"]] = data_file

self.algorithm = alg
simpleapi._set_properties(alg, *(), **kwargs)
simpleapi.set_properties(alg, *(), **kwargs)
alg.execute()
if "OutputMessage" in propertyOrder:
return alg.getPropertyValue("OutputMessage")
Expand Down Expand Up @@ -240,7 +240,7 @@ def execute(self, reducer, inputworkspace=None, outputworkspace=None):
kwargs["OutputWorkspace"] = outputworkspace

self.algorithm = alg
simpleapi._set_properties(alg,*(),**kwargs)
simpleapi.set_properties(alg,*(),**kwargs)
alg.execute()
if "OutputMessage" in propertyOrder:
return alg.getPropertyValue("OutputMessage")
Expand Down

0 comments on commit c50f149

Please sign in to comment.