Skip to content

Commit

Permalink
Merge branch 'feature/10137_pylint_whitespace' into develop
Browse files Browse the repository at this point in the history
Re #10137

Conflicts:
	Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SofQWMoments.py
	Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/Symmetrise.py
  • Loading branch information
peterfpeterson committed Aug 20, 2014
2 parents ed573b0 + 16b61e4 commit 8635fa5
Show file tree
Hide file tree
Showing 220 changed files with 5,726 additions and 5,727 deletions.
8 changes: 4 additions & 4 deletions Code/Mantid/Framework/Algorithms/test/NormaliseToUnityTest.py
Expand Up @@ -5,14 +5,14 @@ class NormaliseToUnityTest(unittest.TestCase):
"""
Simple test to check the numpy integration
"""

def setUp(self):
CreateWorkspace([1,2,3,4,5,6,1,2,3,4,5,6], [1,1,1,1,1,1,1,1,1,1], [1,1,1,1,1,1,1,1,1,1], 2, OutputWorkspace="normalise_to_unity_test")

def tearDown(self):
if mtd.doesExist("normalise_to_unity_test"):
DeleteWorkspace("normalise_to_unity_test")

def test_whole_ws(self):
"""
Check that we can normalize to the sum of all bins
Expand All @@ -25,7 +25,7 @@ def test_whole_ws(self):
def test_x_range(self):
"""
Check that we can specify a range in X and normalize to the sum in that range only
"""
"""
output_ws = NormaliseToUnity("normalise_to_unity_test", RangeLower=2, RangeUpper=4)
self.assertEqual(output_ws.readY(0)[0],0.25)
if output_ws:
Expand All @@ -40,6 +40,6 @@ def test_x_range_and_spectra(self):
self.assertEqual(output_ws.readY(0)[0],0.5)
if output_ws:
DeleteWorkspace(output_ws)

if __name__ == '__main__':
unittest.main()
42 changes: 21 additions & 21 deletions Code/Mantid/Framework/MDEvents/scripts/analysis.py
Expand Up @@ -37,22 +37,22 @@ def plot_results_vs_other(results, x_field, y_field, other_field, extra_title=""
others.add( eval('par.%s' % other_field) )
others = list(others)
others.sort()

figure()

for other in others:
data = []
for par in results:
for par in results:
this_other = eval('par.%s' % other_field)
if this_other == other:
x = eval('par.%s' % x_field)
if this_other == other:
x = eval('par.%s' % x_field)
y = eval('par.%s' % y_field)
data.append( (x,y) )
data.append( (x,y) )
data.sort()
xs = [x for (x,y) in data]
ys = [y for (x,y) in data]
p = plot(xs,ys, marker='.', label="%s = %f" % (other_field, other))

if extra_title != "": extra_title = "\n" + extra_title
title("%s vs %s%s" % (y_field, x_field, extra_title) );
xlabel(x_field)
Expand All @@ -67,25 +67,25 @@ def plot_results_vs_other(results, x_field, y_field, other_field, extra_title=""
def plot_results_with_slope(results, x_field, y_field, x_scale=1):
""" Function to plot Y vs X of anything. It accesses the members of "results" to plot them.
other_field is used to separate by another field, and make separate line plots for each
@param x_scale :: multiply x by this amount
"""
figure()

data = []
for par in results:
x = eval('par.%s' % x_field)
for par in results:
x = eval('par.%s' % x_field)
y = eval('par.%s' % y_field)
data.append( (x,y) )
data.append( (x,y) )
data.sort()
xs = [x*x_scale for (x,y) in data]
ys = [y for (x,y) in data]
# Now get the slope

# Now get the slope
gradient, intercept, r_value, p_value, std_err = stats.linregress(xs,ys)

p = plot(xs,ys, marker='.', label="y = %.3gx + %.3g" % (gradient, intercept))

title("%s vs %s" % (y_field, x_field));
xlabel("%s x %s" % (x_field, x_scale) )
ylabel(y_field)
Expand All @@ -98,21 +98,21 @@ def plot_results_with_slope(results, x_field, y_field, x_scale=1):
#========================================================================================================
def do_analysis(file_list, type):
# Load back the results

results = []
for filename in file_list:
f = open(filename, 'r')
these_results = pickle.load(f)
results += these_results
f.close()

if type == 1:
plot_results_vs_other(results, "SplitInto", "MakeTime", "SplitThresholdBase")
plot_results_vs_other(results, "SplitInto", "MemoryUsed", "SplitThresholdBase")
plot_results_vs_other(results, "SplitInto", "CoarseBinTime", "SplitThresholdBase")
plot_results_vs_other(results, "SplitInto", "MediumBinTime", "SplitThresholdBase")
plot_results_vs_other(results, "SplitInto", "FineBinTime", "SplitThresholdBase")

elif type == 2:
plot_results_with_slope(results, "NumberEvents", "MakeTime", x_scale=1e-9)
plot_results_with_slope(results, "NumberEvents", "MemoryUsed", x_scale=1e-9)
Expand All @@ -128,7 +128,7 @@ def do_analysis(file_list, type):
plot_results_vs_other(results, "SplitThreshold", "MediumBinTime", "SplitInto", extra_title)
plot_results_vs_other(results, "SplitThreshold", "FineBinTime", "SplitInto", extra_title)
show()



#========================================================================================================
Expand All @@ -143,5 +143,5 @@ def do_analysis(file_list, type):

file_list = ["optimize_results1.dat"]
do_analysis(file_list, 1)


34 changes: 17 additions & 17 deletions Code/Mantid/Framework/MDEvents/src/generate_mdevent_declarations.py
Expand Up @@ -9,21 +9,21 @@
# List of every possible MDEvent or MDLeanEvent types.
mdevent_types = ["MDEvent", "MDLeanEvent"]

header = """/* Code below Auto-generated by '%s'
header = """/* Code below Auto-generated by '%s'
* on %s
*
* DO NOT EDIT!
*/
*/
""" % (os.path.basename(__file__), datetime.datetime.now())



footer = """
/* CODE ABOWE WAS AUTO-GENERATED BY %s - DO NOT EDIT! */
/* CODE ABOWE WAS AUTO-GENERATED BY %s - DO NOT EDIT! */
""" % (os.path.basename(__file__))



#============================================================================================================
#============================================================================================================
#============================================================================================================
Expand All @@ -45,7 +45,7 @@ def build_macro(padding,min_dimension=1, max_dimensions=4,const=""):
* @param funcname :: name of the function that will be called.
* @param workspace :: IMDEventWorkspace_sptr input workspace.
*/
#define %sCALL_MDEVENT_FUNCTION%s(funcname, workspace) \\
{ \\
"""
Expand All @@ -61,15 +61,15 @@ def build_macro(padding,min_dimension=1, max_dimensions=4,const=""):
if (min_dimension > 1): suffix = "%d" % min_dimension
if const != "": prefix = "CONST_"
s = macro_top % (prefix, suffix);

for mdevent_type in mdevent_types:
for nd in xrange(1,max_dimensions+1):
if (nd >= min_dimension):
eventType = "%s<%d>" % (mdevent_type, nd)
varname = "MDEW_%s_%d" % (mdevent_type.upper(),nd)
if const != "":
varname = "CONST_" + varname
s += macro % (padding,const, eventType,nd, varname, const, eventType,nd, varname, eventType,nd, varname)
s += macro % (padding,const, eventType,nd, varname, const, eventType,nd, varname, eventType,nd, varname)
s += "} \n \n \n"

return s.split("\n")
Expand Down Expand Up @@ -110,16 +110,16 @@ def find_num_dim(lines):
for i in xrange(len(lines)) :
found = searcher.search(lines[i]);
if found :
rez = found.group()
rez = found.group()
return re.search('\d',rez).group()


raise IOError," can not find the string which defines the number of dimensions to process "



def parse_file(file_name,start_marker,end_marker) :
"""Read the file and separate it into three parts with the part between input markers to be generated and two others left unchanged.
"""Read the file and separate it into three parts with the part between input markers to be generated and two others left unchanged.
@param -- file_name -- full file name to open
@param -- start_marker -- the marker which indicate first line of autogenerated file
Expand Down Expand Up @@ -174,7 +174,7 @@ def generate():
lines +=header_lines;



# ========== Start the header file =============

# Make the macro then pad it into the list of lines
Expand All @@ -197,12 +197,12 @@ def generate():
for nd in dimensions:
lines.append("%s/// Typedef for a %s with %d dimension%s " % (padding,c, nd, ['','s'][nd>1]) )
lines.append("%s typedef %s<%s<%d>, %d> %s%dLean;" % (padding,c, mdevent_type, nd, nd, c, nd) )

lines.append("\n");


lines += footer_lines + lines_after

f = open("../inc/MantidMDEvents/MDEventFactory.h", 'w')
for line in lines:
f.write(line + "\n")
Expand Down Expand Up @@ -233,9 +233,9 @@ def generate():
for nd in dimensions:
lines.append("%s template DLLExport class %s<%s<%d>, %d>;" % (padding,c, mdevent_type, nd, nd) )
lines.append("\n ")


lines += footer_lines+lines_after

lines += footer_lines+lines_after
f = open("./MDEventFactory.cpp", 'w')
for line in lines:
f.write(line+"\n")
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/MPIAlgorithms/scripts/NOM1.py
Expand Up @@ -22,7 +22,7 @@
SNSPowderReduction(Instrument="NOM", RunNumber=runNumber, Extension="_event.nxs",
PreserveEvents=False, PushDataPositive='AddMinimum',
CalibrationFile=cal_file, CharacterizationRunsFile=char_file,
BackgroundNumber=sam_back, VanadiumNumber=van,
BackgroundNumber=sam_back, VanadiumNumber=van,
VanadiumBackgroundNumber=van_back, RemovePromptPulseWidth=50,
Binning=binning, BinInDspace=False, FilterBadPulses=True,
SaveAs="gsas and NeXus", OutputDirectory=outputDir,
Expand Down
Expand Up @@ -43,7 +43,7 @@ def focus(filename):
DiffractionFocussing(InputWorkspace=wksp, OutputWorkspace=wksp,
GroupingWorkspace="grouping", PreserveEvents=False)
return mtd[wksp]


CreateGroupingWorkspace(InstrumentName='NOMAD', GroupNames='NOMAD', OutputWorkspace="grouping")
##CreateGroupingWorkspace(InstrumentName='NOMAD', OldCalFilename=calib, OutputWorkspace="grouping")
Expand Down
22 changes: 11 additions & 11 deletions Code/Mantid/Framework/PythonInterface/mantid/__init__.py
Expand Up @@ -4,16 +4,16 @@
http://www.mantidproject.org
The Mantid project provides a platform that supports high-performance computing
on neutron and muon data. The framework provides a set of common services,
The Mantid project provides a platform that supports high-performance computing
on neutron and muon data. The framework provides a set of common services,
algorithms and data objects that are:
- Instrument or technique independent;
- Supported on multiple target platforms (Windows, Linux, Mac OS X);
- Easily extensible by Instruments Scientists/Users;
- Open source and freely redistributable to visiting scientists;
- Provides functionalities for Scripting, Visualization, Data transformation,
Implementing Algorithms, Virtual Instrument Geometry.
- Provides functionalities for Scripting, Visualization, Data transformation,
Implementing Algorithms, Virtual Instrument Geometry.
"""
###############################################################################
Expand All @@ -33,7 +33,7 @@ def apiVersion():
###############################################################################
# GUI - Do this as early as possible
###############################################################################
# Flag indicating whether the GUI layer is loaded.
# Flag indicating whether the GUI layer is loaded.
try:
import _qti
__gui__ = True
Expand Down Expand Up @@ -63,7 +63,7 @@ def apiVersion():
###############################################################################
import kernel
import geometry
import api
import api

###############################################################################
# Make the aliases form each module accessible in a the mantid namspace
Expand All @@ -80,14 +80,14 @@ def apiVersion():
# Load the Python plugins now everything has started.
#
# Before the plugins are loaded the simpleapi module is called to create
# fake error-raising functions for all of the plugins. After the plugins have been
# fake error-raising functions for all of the plugins. After the plugins have been
# loaded the correction translation is applied to create the "real" simple
# API functions.
#
# Although this seems odd it is necessary so that any PythonAlgorithm
# can call any other PythonAlgorithm through the simple API mechanism. If left
# Although this seems odd it is necessary so that any PythonAlgorithm
# can call any other PythonAlgorithm through the simple API mechanism. If left
# to the simple import mechanism then plugins that are loaded later cannot
# be seen by the earlier ones (chicken & the egg essentially).
# be seen by the earlier ones (chicken & the egg essentially).
################################################################################
import simpleapi as _simpleapi
from kernel import plugins as _plugins
Expand Down Expand Up @@ -116,7 +116,7 @@ def apiVersion():
plugin_modules = _plugins.load(plugin_files)
# Create the proper algorithm definitions in the module
new_attrs = _simpleapi._translate()
# Finally, overwrite the mocked function definitions in the loaded modules with the real ones
# Finally, overwrite the mocked function definitions in the loaded modules with the real ones
_plugins.sync_attrs(_simpleapi, new_attrs, plugin_modules)

################################################################################
6 changes: 3 additions & 3 deletions Code/Mantid/Framework/PythonInterface/mantid/api/__init__.py
Expand Up @@ -25,15 +25,15 @@
###############################################################################
FrameworkManagerImpl.Instance()
# Declare any additional C++ algorithms defined in this package
_api._declareCPPAlgorithms()
_api._declareCPPAlgorithms()

###############################################################################
# Make aliases accessible in this namespace
###############################################################################
from _aliases import *
from _aliases import *

###############################################################################
# Add importAll member to ADS
# Add importAll member to ADS
###############################################################################
import _adsimports

Expand Down

0 comments on commit 8635fa5

Please sign in to comment.