Skip to content

Commit

Permalink
Re #11617. Trying to fix a pylint error.
Browse files Browse the repository at this point in the history
  • Loading branch information
mantid-roman committed Jun 1, 2015
1 parent e502a50 commit c7d4e03
Showing 1 changed file with 33 additions and 16 deletions.
49 changes: 33 additions & 16 deletions Code/Mantid/Framework/PythonInterface/mantid/simpleapi.py
Expand Up @@ -32,7 +32,7 @@

#------------------------ Specialized function calls --------------------------
# List of specialized algorithms
__SPECIALIZED_FUNCTIONS__ = ["Load", "Fit", "CutMD"]
__SPECIALIZED_FUNCTIONS__ = ["Load", "CutMD"]
# List of specialized algorithms
__MDCOORD_FUNCTIONS__ = ["PeakIntensityVsRadius", "CentroidPeaksMD","IntegratePeaksMD"]
# The "magic" keyword to enable/disable logging
Expand Down Expand Up @@ -172,23 +172,15 @@ def LoadDialog(*args, **kwargs):
#---------------------------- Fit ---------------------------------------------

def fitting_algorithm(f):
"""
Decorator generating code for fitting algorithms (currently Fit and CalculateChiSquared).
When applied to a function definition this decorator replaces its code with code of
function 'wrapper' defined below.
"""

function_name = f.__name__

def wrapper(*args, **kwargs):
"""
Fit defines the interface to the fitting 562 within Mantid.
It can work with arbitrary data sources and therefore some options
are only available when the function & workspace type are known.
This simple wrapper takes the Function (as a string) & the InputWorkspace
as the first two arguments. The remaining arguments must be
specified by keyword.
Example:
Fit(Function='name=LinearBackground,A0=0.3', InputWorkspace=dataWS',
StartX='0.05',EndX='1.0',Output="Z1")
"""
Function, InputWorkspace = _get_mandatory_args(function_name, ["Function", "InputWorkspace"], *args, **kwargs)
# Remove from keywords so it is not set twice
if "Function" in kwargs:
Expand Down Expand Up @@ -233,18 +225,43 @@ def wrapper(*args, **kwargs):

# Replace the code object of the wrapper function
wrapper.func_code = _c
wrapper.__doc__ = f.__doc__
if not function_name in __SPECIALIZED_FUNCTIONS__:
__SPECIALIZED_FUNCTIONS__.append(function_name)

return wrapper

# Use a python decorator (defined above) to generate the code for this function.
@fitting_algorithm
def Fit(*args, **kwargs):
pass
"""
Fit defines the interface to the fitting within Mantid.
It can work with arbitrary data sources and therefore some options
are only available when the function & workspace type are known.
This simple wrapper takes the Function (as a string) & the InputWorkspace
as the first two arguments. The remaining arguments must be
specified by keyword.
Example:
Fit(Function='name=LinearBackground,A0=0.3', InputWorkspace=dataWS',
StartX='0.05',EndX='1.0',Output="Z1")
"""
return None

# Use a python decorator (defined above) to generate the code for this function.
@fitting_algorithm
def CalculateChiSquared(*args, **kwargs):
pass
"""
This function calculates chi squared claculation for a function and a data set.
The data set is defined in a way similar to Fit algorithm.
Example:
chi2_1, chi2_2, chi2_3, chi2_4 = \\
CalculateChiSquared(Function='name=LinearBackground,A0=0.3', InputWorkspace=dataWS',
StartX='0.05',EndX='1.0')
"""
return None

def FitDialog(*args, **kwargs):
"""Popup a dialog for the Load algorithm. More help on the Load function
Expand Down

0 comments on commit c7d4e03

Please sign in to comment.