From 04f130b58c111f8f07f0bd86424a0236f7155af3 Mon Sep 17 00:00:00 2001 From: Ross Whitfield Date: Tue, 29 Aug 2017 18:29:28 -0400 Subject: [PATCH] Fix a few misc systemtests for python3 --- .../tests/analysis/BuildSQWTest.py | 3 +- .../tests/analysis/CRISPLoadingTest.py | 1 + .../CalibrateRectangularDetector_Test.py | 6 ++- .../tests/analysis/CodeConventions.py | 43 ++++++++------- .../tests/analysis/ConvertToMDworkflow.py | 9 ++-- .../tests/analysis/CountReflectionsTest.py | 5 +- Testing/SystemTests/tests/analysis/DOSTest.py | 1 + .../analysis/Diffraction_Workflow_Test.py | 3 +- .../tests/analysis/EQSANSIQOutputAPIv2.py | 6 ++- .../tests/analysis/EQSANSSolidAPIv2.py | 3 +- .../tests/analysis/HFIRTestsAPIv2.py | 52 ++++++++++--------- .../tests/analysis/ISISDirectInelastic.py | 5 +- .../analysis/ISISDirectReductionComponents.py | 9 ++-- .../tests/analysis/ISISIndirectBayesTest.py | 6 +-- .../tests/analysis/ISISIndirectInelastic.py | 48 +++++------------ .../analysis/ISISIndirectLoadAsciiTest.py | 3 +- .../analysis/ISISIndirectSimulationTest.py | 3 +- .../tests/analysis/ISISMuonAnalysis.py | 5 +- .../analysis/ISISMuonAnalysisGrouping.py | 5 +- .../analysis/ISISReflInstrumentIDFTest.py | 6 +-- .../analysis/IndirectDiffractionTests.py | 6 +-- .../tests/analysis/LoadAndCheckBase.py | 6 +-- .../tests/analysis/LoadLotsOfInstruments.py | 27 +++++----- .../tests/analysis/MDWorkspaceTests.py | 8 +-- .../analysis/POLDICreatePeaksFromCellTest.py | 15 +++--- .../tests/analysis/POLDIFitPeaks1DTest.py | 3 +- .../tests/analysis/POLDIFitPeaks2DTest.py | 7 +-- .../tests/analysis/Peak2ConvCell_Test.py | 35 +++++++------ .../PowderDiffProfileCalibrateTest.py | 3 +- .../tests/analysis/ReflectometryISIS.py | 6 +-- .../analysis/ReuseExistingCalibration.py | 3 +- .../SANS2DMultiPeriodAddFilesTest_V2.py | 3 +- .../tests/analysis/SEQUOIAreduction.py | 15 +++--- .../tests/analysis/SNSConvertToMDTest.py | 5 +- .../SystemTests/tests/analysis/SXDAnalysis.py | 3 +- .../SystemTests/tests/analysis/SortHKLTest.py | 18 ++++--- .../tests/analysis/SpaceGroupFactoryTest.py | 3 +- .../SpaceGroupReflectionConditionsTest.py | 6 ++- .../tests/analysis/SpaceGroupUnitCellTest.py | 6 ++- .../tests/analysis/SphinxWarnings.py | 6 ++- .../tests/analysis/SurfLoadingTest.py | 1 + .../tests/analysis/TOPAZPeakFinding.py | 3 +- .../tests/analysis/ValidateFacilitiesFile.py | 17 +++--- .../tests/analysis/ValidateGroupingFiles.py | 21 ++++---- .../ValidateInstrumentDefinitionFiles.py | 21 ++++---- .../tests/analysis/ValidateParameterFiles.py | 23 ++++---- .../tests/analysis/WishCalibrate.py | 1 + .../SystemTests/tests/analysis/WishMasking.py | 3 +- 48 files changed, 264 insertions(+), 232 deletions(-) diff --git a/Testing/SystemTests/tests/analysis/BuildSQWTest.py b/Testing/SystemTests/tests/analysis/BuildSQWTest.py index 00d160b73e13..2474dc064d81 100644 --- a/Testing/SystemTests/tests/analysis/BuildSQWTest.py +++ b/Testing/SystemTests/tests/analysis/BuildSQWTest.py @@ -7,6 +7,7 @@ the result file that is ~30Gb. The files are not included with the standard repository & required to be accessible from any machine that wishes to run the test. """ +from __future__ import (absolute_import, division, print_function) import stresstesting import os from mantid.simpleapi import * @@ -70,7 +71,7 @@ def runTest(self): if os.path.exists(target): os.remove(target) - print "Converting '%s' to '%s' " % (source_path,target) + print("Converting '%s' to '%s' " % (source_path,target)) _cur_spe_ws = LoadNXSPE(Filename=source_path) SetUB(Workspace=_cur_spe_ws,a='2.87',b='2.87',c='2.87') # rotated by proper number of degrees around axis Y diff --git a/Testing/SystemTests/tests/analysis/CRISPLoadingTest.py b/Testing/SystemTests/tests/analysis/CRISPLoadingTest.py index 82f082ea6294..8d35434527ef 100644 --- a/Testing/SystemTests/tests/analysis/CRISPLoadingTest.py +++ b/Testing/SystemTests/tests/analysis/CRISPLoadingTest.py @@ -1,3 +1,4 @@ +from __future__ import (absolute_import, division, print_function) from LoadAndCheckBase import * diff --git a/Testing/SystemTests/tests/analysis/CalibrateRectangularDetector_Test.py b/Testing/SystemTests/tests/analysis/CalibrateRectangularDetector_Test.py index 08e20e998fd6..c1c49b2e663b 100644 --- a/Testing/SystemTests/tests/analysis/CalibrateRectangularDetector_Test.py +++ b/Testing/SystemTests/tests/analysis/CalibrateRectangularDetector_Test.py @@ -1,7 +1,9 @@ #pylint: disable=invalid-name,no-init,attribute-defined-outside-init +from __future__ import (absolute_import, division, print_function) import stresstesting import os from mantid.simpleapi import * +from six import string_types def _skip_test(): @@ -41,7 +43,7 @@ def runTest(self): MaxOffset=0.01, PeakPositions = '.6866,.7283,.8185,.8920,1.0758,1.2615,2.0599', CrossCorrelation = False, RunNumber = 'PG3_2538') - if isinstance(output, basestring): + if isinstance(output, string_types): self.saved_cal_file = output.replace('.h5','.cal') else: raise NotImplementedError("Output from CalibrateRectangularDetectors is NOT string for calibration file name!") @@ -89,7 +91,7 @@ def runTest(self): MaxOffset=0.01, PeakPositions = '0.7282933,1.261441',DetectorsPeaks = '17,6', CrossCorrelation = True, RunNumber = 'PG3_2538') - if isinstance(output, basestring): + if isinstance(output, string_types): self.saved_cal_file = output.replace('.h5','.cal') else: raise NotImplementedError("Output from CalibrateRectangularDetectors is NOT string for calibration file name!") diff --git a/Testing/SystemTests/tests/analysis/CodeConventions.py b/Testing/SystemTests/tests/analysis/CodeConventions.py index 687c5c8e436d..06fe703e9675 100644 --- a/Testing/SystemTests/tests/analysis/CodeConventions.py +++ b/Testing/SystemTests/tests/analysis/CodeConventions.py @@ -1,8 +1,11 @@ #pylint: disable=no-init +from __future__ import (absolute_import, division, print_function) import stresstesting import re import mantid from mantid.simpleapi import * +from six.moves import range +from six import iteritems MAX_ALG_LEN = 40 # TODO convention says 20 is the maximum @@ -80,12 +83,12 @@ def __init__(self): def verifyAlgName(self, name): if not self.algRegExp.match(name): - print "Algorithm " + name + " has a name that violates conventions" + print("Algorithm " + name + " has a name that violates conventions") return False if bool(len(name) > MAX_ALG_LEN): - print "%s has a name that is longer than " % name, \ - "%d characters (%d > %d)" % (MAX_ALG_LEN, len(name), MAX_ALG_LEN) + print("%s has a name that is longer than " % name, + "%d characters (%d > %d)" % (MAX_ALG_LEN, len(name), MAX_ALG_LEN)) return False # passed all of the checks @@ -93,11 +96,11 @@ def verifyAlgName(self, name): def verifyCategories(self, name, categories): if len(categories) <= 0: - print name + " has no categories" + print(name + " has no categories") for category in categories: if not self.categoryRegExp.match(category): - print name + " has a bad category " + category + print(name + " has a bad category " + category) return False return True @@ -112,13 +115,13 @@ def verifyProperty(self, alg_descr, name): upper = name.upper() if (upper in SPECIAL_UPPER) and (name not in SPECIAL): index = SPECIAL_UPPER.index(upper) - print alg_descr + " property (" + name + ") has special name "\ - + "with wrong case: " + name + " should be " + SPECIAL[index] + print(alg_descr + " property (" + name + ") has special name " + + "with wrong case: " + name + " should be " + SPECIAL[index]) return False if not self.paramRegExp.match(name): if not self.checkAllowed(alg_descr, name): - print alg_descr + " property (" + name +") violates conventions" + print(alg_descr + " property (" + name +") violates conventions") return False # passed all of the checks @@ -127,7 +130,7 @@ def verifyProperty(self, alg_descr, name): def runTest(self): algs = AlgorithmFactory.getRegisteredAlgorithms(True) - for (name, versions) in algs.iteritems(): + for (name, versions) in iteritems(algs): if not self.verifyAlgName(name): self.__ranOk += 1 continue @@ -148,8 +151,8 @@ def runTest(self): def validate(self): if self.__ranOk > 0: - print "Found %d errors. Coding conventions found at" % self.__ranOk,\ - "http://www.mantidproject.org/Mantid_Standards" + print("Found %d errors. Coding conventions found at" % self.__ranOk, + "http://www.mantidproject.org/Mantid_Standards") return False return True @@ -168,12 +171,12 @@ def verifyFuncName(self, name): return True if not self.funcRegExp.match(name): - print "Function " + name + " has a name that violates conventions" + print("Function " + name + " has a name that violates conventions") return False if bool(len(name) > MAX_ALG_LEN): - print "%s has a name that is longer than " % name, \ - "%d characters (%d > %d)" % (MAX_ALG_LEN, len(name), MAX_ALG_LEN) + print("%s has a name that is longer than " % name, + "%d characters (%d > %d)" % (MAX_ALG_LEN, len(name), MAX_ALG_LEN)) return False # passed all of the checks @@ -181,7 +184,7 @@ def verifyFuncName(self, name): def verifyCategories(self, name, categories): if len(categories) <= 0: - print name + " has no categories" + print(name + " has no categories") for category in categories: # TODO remove the special case @@ -189,7 +192,7 @@ def verifyCategories(self, name, categories): return True if not self.categoryRegExp.match(category): - print name + " has a bad category " + category + print(name + " has a bad category " + category) return False return True @@ -204,7 +207,7 @@ def verifyParameter(self, alg_descr, name): if not self.paramRegExp.match(name): if not self.checkAllowed(alg_descr, name): - print alg_descr + " property (" + name +") violates conventions" + print(alg_descr + " property (" + name +") violates conventions") return False # passed all of the checks @@ -222,14 +225,14 @@ def runTest(self): if not self.verifyCategories(name, function.categories()): self.__ranOk += 1 - for i in xrange(function.numParams()): + for i in range(function.numParams()): if not self.verifyParameter(name, function.getParamName(i)): self.__ranOk += 1 def validate(self): if self.__ranOk > 0: - print "Found %d errors. Coding conventions found at" % self.__ranOk,\ - "http://www.mantidproject.org/Mantid_Standards" + print("Found %d errors. Coding conventions found at" % self.__ranOk, + "http://www.mantidproject.org/Mantid_Standards") return False return True diff --git a/Testing/SystemTests/tests/analysis/ConvertToMDworkflow.py b/Testing/SystemTests/tests/analysis/ConvertToMDworkflow.py index efd58983b550..cd01315d34f4 100644 --- a/Testing/SystemTests/tests/analysis/ConvertToMDworkflow.py +++ b/Testing/SystemTests/tests/analysis/ConvertToMDworkflow.py @@ -1,4 +1,5 @@ #pylint: disable=no-init +from __future__ import (absolute_import, division, print_function) import stresstesting from mantid.simpleapi import * @@ -27,10 +28,10 @@ def runTest(self): try: DeleteWorkspace(RezWS) except ValueError: - print "Target ws ",RezWS," not found in analysis data service\n" + print("Target ws ",RezWS," not found in analysis data service\n") # #---> Start loop over contributing files - for i in xrange(0,20,5): + for i in range(0,20,5): # the following operations simulate different workspaces, obtained from experiment using rotating crystal; # For real experiment we usually just load these workspaces from nxspe files with proper Psi values defined there # and have to set up ub matrix @@ -72,8 +73,8 @@ def validate(self): checker.execute() if checker.getPropertyValue("Equals") != "1": - print " Workspaces do not match, result: ",checker.getPropertyValue("Result") - print self.__class__.__name__ + print(" Workspaces do not match, result: ",checker.getPropertyValue("Result")) + print(self.__class__.__name__) SaveMD(InputWorkspace=valNames[0],Filename=self.__class__.__name__+'-mismatch.nxs') return False diff --git a/Testing/SystemTests/tests/analysis/CountReflectionsTest.py b/Testing/SystemTests/tests/analysis/CountReflectionsTest.py index 1e919ac4ee19..3d058d2c3dcf 100644 --- a/Testing/SystemTests/tests/analysis/CountReflectionsTest.py +++ b/Testing/SystemTests/tests/analysis/CountReflectionsTest.py @@ -1,3 +1,4 @@ +from __future__ import (absolute_import, division, print_function) import stresstesting from mantid.simpleapi import * from SortHKLTest import HKLStatisticsTestMixin @@ -32,8 +33,8 @@ def _run_count_reflections(self, reflections, space_group): LatticeCentering=centering, MinDSpacing=0.5, MaxDSpacing=10.0) def _compare_statistics(self, statistics, reference_statistics): - self.assertEquals(round(statistics['Redundancy'], 1), round(reference_statistics[''], 1)) - self.assertEquals(statistics['UniqueReflections'], int(reference_statistics['Nunique'])) + self.assertEqual(round(statistics['Redundancy'], 1), round(reference_statistics[''], 1)) + self.assertEqual(statistics['UniqueReflections'], int(reference_statistics['Nunique'])) self.assertDelta(round(statistics['Completeness'] * 100.0, 1), round(reference_statistics['Completeness'], 1), 0.5) diff --git a/Testing/SystemTests/tests/analysis/DOSTest.py b/Testing/SystemTests/tests/analysis/DOSTest.py index 7e28c5afa63c..68b2787b92e0 100644 --- a/Testing/SystemTests/tests/analysis/DOSTest.py +++ b/Testing/SystemTests/tests/analysis/DOSTest.py @@ -1,4 +1,5 @@ #pylint: disable=no-init,attribute-defined-outside-init +from __future__ import (absolute_import, division, print_function) import stresstesting from mantid.kernel import * from mantid.api import * diff --git a/Testing/SystemTests/tests/analysis/Diffraction_Workflow_Test.py b/Testing/SystemTests/tests/analysis/Diffraction_Workflow_Test.py index 5aa27f7d2683..13d4ae3fa1cd 100644 --- a/Testing/SystemTests/tests/analysis/Diffraction_Workflow_Test.py +++ b/Testing/SystemTests/tests/analysis/Diffraction_Workflow_Test.py @@ -3,6 +3,7 @@ System test that loads TOPAZ single-crystal data, and runs Diffraction Workflow. """ +from __future__ import (absolute_import, division, print_function) import stresstesting import numpy import os @@ -153,7 +154,7 @@ def runTest(self): newUB = numpy.array(mtd["TOPAZ_3132"].sample().getOrientedLattice().getUB()) # UB Matrices are not necessarily the same, some of the H,K and/or L sign can be reversed diff = abs(newUB) - abs(originalUB) < 0.001 - for c in xrange(3): + for c in range(3): # This compares each column, allowing old == new OR old == -new if not numpy.all(diff[:,c]) : raise Exception("More than 0.001 difference between UB matrices: Q (lab frame):\n%s\nQ (sample frame):\n%s" diff --git a/Testing/SystemTests/tests/analysis/EQSANSIQOutputAPIv2.py b/Testing/SystemTests/tests/analysis/EQSANSIQOutputAPIv2.py index ab569c401bd7..6b3ac508ba79 100644 --- a/Testing/SystemTests/tests/analysis/EQSANSIQOutputAPIv2.py +++ b/Testing/SystemTests/tests/analysis/EQSANSIQOutputAPIv2.py @@ -1,4 +1,5 @@ #pylint: disable=no-init,invalid-name,attribute-defined-outside-init +from __future__ import (absolute_import, division, print_function) import stresstesting import math import os @@ -6,6 +7,7 @@ from reduction_workflow.instruments.sans.sns_command_interface import * from reduction_workflow.instruments.sans.hfir_command_interface import * from mantid.api import * +from functools import reduce def do_cleanup(): @@ -192,7 +194,7 @@ def validate(self): output = reduce(lambda x,y:x and y, diff) if not output: for i,dqi in enumerate(dq): - print i, dqi, dq_ref[i], math.fabs(dq_ref[i]-dqi)<0.0001 + print(i, dqi, dq_ref[i], math.fabs(dq_ref[i]-dqi)<0.0001) return output @@ -258,5 +260,5 @@ def validate(self): if not output: for i,dqi in enumerate(dq): - print i, dqi, dq_ref[i], math.fabs(dq_ref[i]-dqi)<0.0001 + print(i, dqi, dq_ref[i], math.fabs(dq_ref[i]-dqi)<0.0001) return output diff --git a/Testing/SystemTests/tests/analysis/EQSANSSolidAPIv2.py b/Testing/SystemTests/tests/analysis/EQSANSSolidAPIv2.py index f518d2ca37e7..3e08e14c4460 100644 --- a/Testing/SystemTests/tests/analysis/EQSANSSolidAPIv2.py +++ b/Testing/SystemTests/tests/analysis/EQSANSSolidAPIv2.py @@ -1,4 +1,5 @@ #pylint: disable=no-init,attribute-defined-outside-init +from __future__ import (absolute_import, division, print_function) import stresstesting from mantid.simpleapi import * from reduction_workflow.instruments.sans.sns_command_interface import * @@ -12,7 +13,7 @@ def do_cleanup(): absfile = FileFinder.getFullPath("EQSANS_1466_event_reduction.log") if os.path.exists(absfile): os.remove(absfile) - print "cleaned" + print("cleaned") return True diff --git a/Testing/SystemTests/tests/analysis/HFIRTestsAPIv2.py b/Testing/SystemTests/tests/analysis/HFIRTestsAPIv2.py index 43d23b90f658..2741b928a36f 100644 --- a/Testing/SystemTests/tests/analysis/HFIRTestsAPIv2.py +++ b/Testing/SystemTests/tests/analysis/HFIRTestsAPIv2.py @@ -7,6 +7,7 @@ The following tests were converted from the unittest framework that is part of python to the stresstesting framework used in Mantid. """ +from __future__ import (absolute_import, division, print_function) import types import traceback @@ -18,6 +19,7 @@ from mantid.simpleapi import * from reduction_workflow.instruments.sans.hfir_command_interface import * from reduction_workflow.command_interface import AppendDataFile, Reduce, Reduce1D +from functools import reduce # Set directory containing the test data, relative to the Mantid release @@ -58,7 +60,7 @@ def _read_IGOR(filepath): diq = float(toks[2]) data.append([q, iq, diq]) except: - print "_read_IGOR:", sys.exc_value + print("_read_IGOR:", sys.exc_info()[1]) raise return data @@ -75,14 +77,14 @@ def _check_result(ws, test_file, tolerance=1e-6): x = ws.dataX(0)[:len(ws.dataX(0))] y = ws.dataY(0) e = ws.dataE(0) - data_mantid = zip(x, y, e) + data_mantid = list(zip(x, y, e)) # Read the test data to compare with data_igor = _read_IGOR(test_file) # Check length if not len(data_mantid) == len(data_igor): - print "Incompatible data lengths" + print("Incompatible data lengths") return False # Utility methods for manipulating the lists @@ -99,25 +101,25 @@ def _add(x, y): return x + y # Check that I(q) is the same for both data sets - deltas = map(_diff_iq, data_mantid, data_igor) + deltas = list(map(_diff_iq, data_mantid, data_igor)) delta = reduce(_add, deltas) / len(deltas) if math.fabs(delta) > tolerance or math.isnan(delta): passed = False - print "Sum of I(q) deltas is outside tolerance: %g > %g" % (math.fabs(delta), tolerance) + print("Sum of I(q) deltas is outside tolerance: %g > %g" % (math.fabs(delta), tolerance)) # Then compare the errors - deltas = map(_diff_err, data_mantid, data_igor) + deltas = list(map(_diff_err, data_mantid, data_igor)) delta_err = reduce(_add, deltas) / len(deltas) if math.fabs(delta_err) > tolerance or math.isnan(delta): passed = False - print "Sum of dI(q) deltas is outside tolerance: %g > %g" % (math.fabs(delta_err), tolerance) + print("Sum of dI(q) deltas is outside tolerance: %g > %g" % (math.fabs(delta_err), tolerance)) # Compute chi2 of our result relative to IGOR - deltas = map(_diff_chi2, data_mantid, data_igor) + deltas = list(map(_diff_chi2, data_mantid, data_igor)) chi2 = reduce(_add, deltas) / len(data_igor) if chi2 > 10.0 * tolerance or math.isnan(delta): passed = False - print "Chi2 is outside tolerance: %g > %g" % (chi2, 10.0 * tolerance) + print("Chi2 is outside tolerance: %g > %g" % (chi2, 10.0 * tolerance)) return passed @@ -184,10 +186,10 @@ def run_test(self): ReductionSingleton.clean() # Execute the test try: - print self._test_method.__name__ + print(self._test_method.__name__) return self._test_method() except: - print traceback.format_exc() + print(traceback.format_exc()) raise return False @@ -360,7 +362,7 @@ def test_reduction_1(self): 0.192082, 0.193783, 0.193787, 0.190557, 0.190471, 0.186827, 0.190088, 0.188204, 0.187547, 0.182206, 0.181384, 0.180358, 0.182663, 0.178844, 0.176556] - deltas = map(_diff_iq, data, check) + deltas = list(map(_diff_iq, data, check)) delta = reduce(_add, deltas) / len(deltas) self.assertTrue(math.fabs(delta) < 0.00001) @@ -415,10 +417,10 @@ def test_reduction_iqxqy(self): 0.05658625,0.05933774,0.06222303,0.06524861,0.06842131,0.07174829, 0.07523703,0.07889542,0.08273169,0.08675451,0.09097293,0.09539647, 0.1000351,0.10489929,0.11] - deltas = map(_diff_iq, data, check) + deltas = list(map(_diff_iq, data, check)) delta = reduce(_add, deltas) / len(deltas) self.assertTrue(math.fabs(delta) < 0.00001) - print data + print(data) def test_no_solid_angle(self): GPSANS() @@ -471,7 +473,7 @@ def test_reduction_2(self): 0.190122, 0.189119, 0.18864, 0.185473, 0.184958, 0.183981, 0.182581] - deltas = map(_diff_iq, data, check) + deltas = list(map(_diff_iq, data, check)) delta = reduce(_add, deltas) / len(deltas) self.assertTrue(math.fabs(delta) < 0.00001) @@ -504,7 +506,7 @@ def test_straight_Q1D(self): 0.195653, 0.19322, 0.193537, 0.191503, 0.190253, 0.189253, 0.188771, 0.1856, 0.185099, 0.184111, 0.182717] - deltas = map(_diff_iq, data, check) + deltas = list(map(_diff_iq, data, check)) delta = reduce(_add, deltas) / len(deltas) self.assertTrue(math.fabs(delta) < 0.00001) @@ -540,7 +542,7 @@ def test_transmission(self): 0.369733, 0.370353, 0.366464, 0.364109, 0.362184, 0.361299, 0.355246, 0.354339, 0.352412, 0.349748] - deltas = map(_diff_iq, data, check) + deltas = list(map(_diff_iq, data, check)) delta = reduce(_add, deltas) / len(deltas) self.assertTrue(math.fabs(delta) < 0.001) @@ -693,12 +695,12 @@ def test_transmission_by_hand_w_sensitivity(self): 0.3479, 0.352355, 0.344987, 0.340605] # Check that I(q) is the same for both data sets - deltas = map(_diff_iq, data, check) + deltas = list(map(_diff_iq, data, check)) delta = reduce(_add, deltas) / len(deltas) self.assertTrue(math.fabs(delta) < 0.00001) def test_SampleGeometry_functions(self): - print "SKIPPING test_SampleGeometry_functions()" + print("SKIPPING test_SampleGeometry_functions()") return # pylint: disable=unreachable GPSANS() @@ -724,7 +726,7 @@ def test_SampleGeometry_functions(self): check = [500091.0, 60.0, 40.8333, 13.6333, 13.4667, 13.6667] # Check that I(q) is the same for both data sets - deltas = map(_diff_iq, data, check) + deltas = list(map(_diff_iq, data, check)) delta = reduce(_add, deltas) / len(deltas) self.assertTrue(math.fabs(delta) < 0.1) @@ -948,9 +950,9 @@ def test_bck_transmission_direct_beam_center(self): self.assertAlmostEqual(data[20], -0.047785, delta=0.00001) def validate(self): - print "HFIRTests: %d / %d tests passed" % (self.n_passed, self.n_tests) + print("HFIRTests: %d / %d tests passed" % (self.n_passed, self.n_tests)) for items in self.failed_tests: - print items + print(items) return self.all_passed @@ -970,9 +972,9 @@ def assertAlmostEqual(first, second, places=None, _msg=None, delta=None, rel_del if abs(first - second) <= delta: return True elif abs(first - second) / abs(second) < rel_delta: - print '\n-----> %s != %s but within %s percent' % (str(first), + print('\n-----> %s != %s but within %s percent' % (str(first), str(second), - str(rel_delta * 100.0)) + str(rel_delta * 100.0))) return True standardMsg = '%s != %s within %s delta' % (str(first), @@ -988,5 +990,5 @@ def assertAlmostEqual(first, second, places=None, _msg=None, delta=None, rel_del standardMsg = '%s != %s within %r places' % (str(first), str(second), places) - print standardMsg + print(standardMsg) return False diff --git a/Testing/SystemTests/tests/analysis/ISISDirectInelastic.py b/Testing/SystemTests/tests/analysis/ISISDirectInelastic.py index be3b522cb919..c7f573bea9b6 100644 --- a/Testing/SystemTests/tests/analysis/ISISDirectInelastic.py +++ b/Testing/SystemTests/tests/analysis/ISISDirectInelastic.py @@ -1,4 +1,5 @@ #pylint: disable=no-init +from __future__ import (absolute_import, division, print_function) import stresstesting from mantid.simpleapi import * from mantid.api import Workspace @@ -7,10 +8,11 @@ from abc import ABCMeta, abstractmethod from Direct.PropertyManager import PropertyManager +from six import with_metaclass #---------------------------------------------------------------------- -class ISISDirectInelasticReduction(stresstesting.MantidStressTest): +class ISISDirectInelasticReduction(with_metaclass(ABCMeta, stresstesting.MantidStressTest)): """A base class for the ISIS direct inelastic tests The workflow is defined in the runTest() method, simply @@ -27,7 +29,6 @@ class ISISDirectInelasticReduction(stresstesting.MantidStressTest): - sample_rmm: A float value for the sample rmm or None - hard_mask: An hard mask file or None """ - __metaclass__ = ABCMeta # Mark as an abstract class tolerance=0. tolerance_is_reller=True diff --git a/Testing/SystemTests/tests/analysis/ISISDirectReductionComponents.py b/Testing/SystemTests/tests/analysis/ISISDirectReductionComponents.py index de92eb1094d7..808478796a3c 100644 --- a/Testing/SystemTests/tests/analysis/ISISDirectReductionComponents.py +++ b/Testing/SystemTests/tests/analysis/ISISDirectReductionComponents.py @@ -1,4 +1,5 @@ #pylint: disable=invalid-name +from __future__ import (absolute_import, division, print_function) import os import sys import stresstesting @@ -112,12 +113,12 @@ def runTest(self): rez,mess = rd.run_reduction() self.result=rez if not rez: - print "*** Validation failed: {0}".format(mess) + print("*** Validation failed: {0}".format(mess)) if mess.find('Created')>-1: # validation still failed due to missing validation file - print "*** Validation failed: {0}".format(mess) + print("*** Validation failed: {0}".format(mess)) self.result=False except RuntimeError as err: - print "*** Validation failed with error: {0}".format(err.message) + print("*** Validation failed with error: {0}".format(err.message)) self.result=False rd.reducer.prop_man.save_file_name = None @@ -243,7 +244,7 @@ def runTest(self): self.assertTrue(isinstance(ei_ws,Workspace)) en_peaks = ei_ws.readX(0) - self.assertAlmostEquals(len(en_peaks),1) + self.assertAlmostEqual(len(en_peaks),1) self.assertAlmostEqual(en_peaks[0],108.94,2) self.valid = True diff --git a/Testing/SystemTests/tests/analysis/ISISIndirectBayesTest.py b/Testing/SystemTests/tests/analysis/ISISIndirectBayesTest.py index d52af1e7e6c8..23bbc3641272 100644 --- a/Testing/SystemTests/tests/analysis/ISISIndirectBayesTest.py +++ b/Testing/SystemTests/tests/analysis/ISISIndirectBayesTest.py @@ -1,9 +1,11 @@ #pylint: disable=no-init,attribute-defined-outside-init, too-few-public-methods +from __future__ import (absolute_import, division, print_function) import stresstesting import os from abc import ABCMeta, abstractmethod from mantid.simpleapi import * import platform +from six import with_metaclass #============================================================================== @@ -316,9 +318,7 @@ def cleanup(self): #============================================================================== -class JumpFitFunctionTestBase(stresstesting.MantidStressTest): - - __metaclass__ = ABCMeta +class JumpFitFunctionTestBase(with_metaclass(ABCMeta, stresstesting.MantidStressTest)): def __init__(self): stresstesting.MantidStressTest.__init__(self) diff --git a/Testing/SystemTests/tests/analysis/ISISIndirectInelastic.py b/Testing/SystemTests/tests/analysis/ISISIndirectInelastic.py index 5d4b77256ede..4b74f53b4979 100644 --- a/Testing/SystemTests/tests/analysis/ISISIndirectInelastic.py +++ b/Testing/SystemTests/tests/analysis/ISISIndirectInelastic.py @@ -67,6 +67,7 @@ | ''' +from __future__ import (absolute_import, division, print_function) import stresstesting import os from abc import ABCMeta, abstractmethod @@ -75,15 +76,14 @@ # For debugging only. from mantid.api import FileFinder +from six import with_metaclass -class ISISIndirectInelasticBase(stresstesting.MantidStressTest): +class ISISIndirectInelasticBase(with_metaclass(ABCMeta, stresstesting.MantidStressTest)): ''' A common base class for the ISISIndirectInelastic* base classes. ''' - __metaclass__ = ABCMeta # Mark as an abstract class - @abstractmethod def get_reference_files(self): '''Returns the name of the reference files to compare against.''' @@ -138,7 +138,7 @@ def validate(self): reference_file) if not self.validateWorkspaces([result, wsName]): - print str([reference_file, result]) + " do not match." + print(str([reference_file, result]) + " do not match.") return False return True @@ -151,7 +151,7 @@ def get_temp_dir_path(self, filename): #============================================================================== -class ISISIndirectInelasticReduction(ISISIndirectInelasticBase): +class ISISIndirectInelasticReduction(with_metaclass(ABCMeta, ISISIndirectInelasticBase)): '''A base class for the ISIS indirect inelastic reduction tests The workflow is defined in the _run() method, simply @@ -165,8 +165,6 @@ class ISISIndirectInelasticReduction(ISISIndirectInelasticBase): - save_formats: A list containing the file extensions of the formats to save to. ''' - - __metaclass__ = ABCMeta # Mark as an abstract class sum_files = False def _run(self): @@ -337,7 +335,7 @@ def get_reference_files(self): #============================================================================== -class ISISIndirectInelasticCalibration(ISISIndirectInelasticBase): +class ISISIndirectInelasticCalibration(with_metaclass(ABCMeta, ISISIndirectInelasticBase)): '''A base class for the ISIS indirect inelastic calibration tests The workflow is defined in the _run() method, simply @@ -351,8 +349,6 @@ class ISISIndirectInelasticCalibration(ISISIndirectInelasticBase): - self.reflection: a string giving the reflection to use ''' - __metaclass__ = ABCMeta # Mark as an abstract class - def _run(self): '''Defines the workflow for the test''' self.tolerance = 1e-7 @@ -410,7 +406,7 @@ def get_reference_files(self): #============================================================================== -class ISISIndirectInelasticResolution(ISISIndirectInelasticBase): +class ISISIndirectInelasticResolution(with_metaclass(ABCMeta, ISISIndirectInelasticBase)): '''A base class for the ISIS indirect inelastic resolution tests The workflow is defined in the _run() method, simply @@ -425,8 +421,6 @@ class ISISIndirectInelasticResolution(ISISIndirectInelasticBase): - self.files: a list of strings containing filenames ''' - __metaclass__ = ABCMeta # Mark as an abstract class - def _run(self): '''Defines the workflow for the test''' self.tolerance = 1e-7 @@ -500,7 +494,7 @@ def get_reference_files(self): #============================================================================== -class ISISIndirectInelasticDiagnostics(ISISIndirectInelasticBase): +class ISISIndirectInelasticDiagnostics(with_metaclass(ABCMeta, ISISIndirectInelasticBase)): '''A base class for the ISIS indirect inelastic diagnostic tests The workflow is defined in the _run() method, simply @@ -508,8 +502,6 @@ class ISISIndirectInelasticDiagnostics(ISISIndirectInelasticBase): on the object ''' - __metaclass__ = ABCMeta # Mark as an abstract class - def _run(self): '''Defines the workflow for the test''' @@ -576,14 +568,12 @@ def get_reference_files(self): #============================================================================== -class ISISIndirectInelasticMoments(ISISIndirectInelasticBase): +class ISISIndirectInelasticMoments(with_metaclass(ABCMeta, ISISIndirectInelasticBase)): '''A base class for the ISIS indirect inelastic TransformToIqt/TransformToIqtFit tests The output of Elwin is usually used with MSDFit and so we plug one into the other in this test. ''' - # Mark as an abstract class - __metaclass__ = ABCMeta def _run(self): '''Defines the workflow for the test''' @@ -642,15 +632,13 @@ def get_reference_files(self): #============================================================================== -class ISISIndirectInelasticElwinAndMSDFit(ISISIndirectInelasticBase): +class ISISIndirectInelasticElwinAndMSDFit(with_metaclass(ABCMeta, ISISIndirectInelasticBase)): '''A base class for the ISIS indirect inelastic Elwin/MSD Fit tests The output of Elwin is usually used with MSDFit and so we plug one into the other in this test. ''' - __metaclass__ = ABCMeta # Mark as an abstract class - def _run(self): '''Defines the workflow for the test''' self.tolerance = 1e-7 @@ -743,7 +731,7 @@ def get_reference_files(self): #============================================================================== -class ISISIndirectInelasticIqtAndIqtFit(ISISIndirectInelasticBase): +class ISISIndirectInelasticIqtAndIqtFit(with_metaclass(ABCMeta, ISISIndirectInelasticBase)): ''' A base class for the ISIS indirect inelastic Iqt/IqtFit tests @@ -751,8 +739,6 @@ class ISISIndirectInelasticIqtAndIqtFit(ISISIndirectInelasticBase): the other in this test. ''' - __metaclass__ = ABCMeta # Mark as an abstract class - def _run(self): '''Defines the workflow for the test''' self.tolerance = 1e-7 @@ -871,15 +857,13 @@ def get_reference_files(self): #============================================================================== -class ISISIndirectInelasticIqtAndIqtFitMulti(ISISIndirectInelasticBase): +class ISISIndirectInelasticIqtAndIqtFitMulti(with_metaclass(ABCMeta, ISISIndirectInelasticBase)): '''A base class for the ISIS indirect inelastic Iqt/IqtFit tests The output of Elwin is usually used with MSDFit and so we plug one into the other in this test. ''' - __metaclass__ = ABCMeta # Mark as an abstract class - def _run(self): '''Defines the workflow for the test''' self.tolerance = 1e-6 @@ -1000,15 +984,13 @@ def get_reference_files(self): #============================================================================== -class ISISIndirectInelasticConvFit(ISISIndirectInelasticBase): +class ISISIndirectInelasticConvFit(with_metaclass(ABCMeta, ISISIndirectInelasticBase)): '''A base class for the ISIS indirect inelastic ConvFit tests The workflow is defined in the _run() method, simply define an __init__ method and set the following properties on the object ''' - # Mark as an abstract class - __metaclass__ = ABCMeta def _run(self): '''Defines the workflow for the test''' @@ -1109,10 +1091,8 @@ def get_reference_files(self): # Transmission Monitor Test -class ISISIndirectInelasticTransmissionMonitor(ISISIndirectInelasticBase): +class ISISIndirectInelasticTransmissionMonitor(with_metaclass(ABCMeta, ISISIndirectInelasticBase)): # Mark as an abstract class - __metaclass__ = ABCMeta - def _run(self): '''Defines the workflow for the test''' diff --git a/Testing/SystemTests/tests/analysis/ISISIndirectLoadAsciiTest.py b/Testing/SystemTests/tests/analysis/ISISIndirectLoadAsciiTest.py index 8c0a7d58c4d1..94819aaddeb5 100644 --- a/Testing/SystemTests/tests/analysis/ISISIndirectLoadAsciiTest.py +++ b/Testing/SystemTests/tests/analysis/ISISIndirectLoadAsciiTest.py @@ -1,4 +1,5 @@ #pylint: disable=no-init,attribute-defined-outside-init +from __future__ import (absolute_import, division, print_function) import stresstesting import mantid.simpleapi as ms @@ -70,7 +71,7 @@ def checkWorkspacesMatch(self, ws1, ws2): checker.execute() if not checker.getProperty("Result"): - print self.__class__.__name__ + print(self.__class__.__name__) ms.SaveNexus(InputWorkspace=ws2,Filename=self.__class__.__name__+'-mismatch.nxs') return False diff --git a/Testing/SystemTests/tests/analysis/ISISIndirectSimulationTest.py b/Testing/SystemTests/tests/analysis/ISISIndirectSimulationTest.py index 42abb848d014..a434e39adce4 100644 --- a/Testing/SystemTests/tests/analysis/ISISIndirectSimulationTest.py +++ b/Testing/SystemTests/tests/analysis/ISISIndirectSimulationTest.py @@ -1,4 +1,5 @@ #pylint: disable=no-init,attribute-defined-outside-init +from __future__ import (absolute_import, division, print_function) import stresstesting import mantid.simpleapi as ms @@ -43,7 +44,7 @@ def checkWorkspacesMatch(self, ws1, ws2): checker.execute() if not checker.getProperty("Result"): - print self.__class__.__name__ + print(self.__class__.__name__) ms.SaveNexus(InputWorkspace=ws2,Filename=self.__class__.__name__+'-mismatch.nxs') return False diff --git a/Testing/SystemTests/tests/analysis/ISISMuonAnalysis.py b/Testing/SystemTests/tests/analysis/ISISMuonAnalysis.py index 098cb1749781..24892a5d36ef 100644 --- a/Testing/SystemTests/tests/analysis/ISISMuonAnalysis.py +++ b/Testing/SystemTests/tests/analysis/ISISMuonAnalysis.py @@ -1,14 +1,16 @@ #pylint: disable=no-init,invalid-name,attribute-defined-outside-init,too-many-instance-attributes,too-few-public-methods +from __future__ import (absolute_import, division, print_function) import math import stresstesting from mantid.simpleapi import * from abc import ABCMeta, abstractmethod +from six import with_metaclass #---------------------------------------------------------------------- -class ISISMuonAnalysis(stresstesting.MantidStressTest): +class ISISMuonAnalysis(with_metaclass(ABCMeta, stresstesting.MantidStressTest)): """A base class for the ISIS Muon Analysis tests The workflow is defined in the runTest() method, simply @@ -26,7 +28,6 @@ class ISISMuonAnalysis(stresstesting.MantidStressTest): - rebin_fixed: Optional boolean to tell if the rebinning is in fixed steps. - rebin_params: A string containing the rebin parameters. See wiki rebin for more info. """ - __metaclass__ = ABCMeta # Mark as an abstract class @abstractmethod def get_reference_file(self): diff --git a/Testing/SystemTests/tests/analysis/ISISMuonAnalysisGrouping.py b/Testing/SystemTests/tests/analysis/ISISMuonAnalysisGrouping.py index 5cd48d7c1f91..ff003fb298a7 100644 --- a/Testing/SystemTests/tests/analysis/ISISMuonAnalysisGrouping.py +++ b/Testing/SystemTests/tests/analysis/ISISMuonAnalysisGrouping.py @@ -1,13 +1,15 @@ #pylint: disable=no-init,attribute-defined-outside-init,too-many-instance-attributes,too-few-public-methods +from __future__ import (absolute_import, division, print_function) import stresstesting from mantid.simpleapi import * from abc import ABCMeta, abstractmethod +from six import with_metaclass #---------------------------------------------------------------------- -class ISISMuonAnalysisGrouping(stresstesting.MantidStressTest): +class ISISMuonAnalysisGrouping(with_metaclass(ABCMeta, stresstesting.MantidStressTest)): """A base class for the ISIS Muon Analysis tests The workflow is defined in the runTest() method, simply @@ -23,7 +25,6 @@ class ISISMuonAnalysisGrouping(stresstesting.MantidStressTest): - x_min: Float value of the minimum x. - x_max: Float value of the maximum x. """ - __metaclass__ = ABCMeta # Mark as an abstract class @abstractmethod def get_reference_file(self): diff --git a/Testing/SystemTests/tests/analysis/ISISReflInstrumentIDFTest.py b/Testing/SystemTests/tests/analysis/ISISReflInstrumentIDFTest.py index 507b008c4802..93531a2f562e 100644 --- a/Testing/SystemTests/tests/analysis/ISISReflInstrumentIDFTest.py +++ b/Testing/SystemTests/tests/analysis/ISISReflInstrumentIDFTest.py @@ -3,15 +3,15 @@ These system tests are to verify that the IDF and parameter files for POLREF, CRISP, INTER and SURF are read properly """ +from __future__ import (absolute_import, division, print_function) import stresstesting from mantid.simpleapi import * import os from abc import ABCMeta, abstractmethod +from six import with_metaclass -class ISISReflInstrumentIDFTest(stresstesting.MantidStressTest): - - __metaclass__ = ABCMeta # Mark as an abstract class +class ISISReflInstrumentIDFTest(with_metaclass(ABCMeta, stresstesting.MantidStressTest)): @abstractmethod def get_IDF_name(self): diff --git a/Testing/SystemTests/tests/analysis/IndirectDiffractionTests.py b/Testing/SystemTests/tests/analysis/IndirectDiffractionTests.py index 075edc1ad262..f080bf13ca71 100644 --- a/Testing/SystemTests/tests/analysis/IndirectDiffractionTests.py +++ b/Testing/SystemTests/tests/analysis/IndirectDiffractionTests.py @@ -1,18 +1,18 @@ #pylint: disable=no-init,non-parent-init-called,too-few-public-methods # non-parent-init-called is disabled to remove false positives from a bug in pyLint < 1.4 +from __future__ import (absolute_import, division, print_function) from abc import ABCMeta, abstractmethod import stresstesting import mantid.simpleapi as ms from mantid import mtd +from six import with_metaclass -class ISISIndirectDiffractionReduction(stresstesting.MantidStressTest): +class ISISIndirectDiffractionReduction(with_metaclass(ABCMeta, stresstesting.MantidStressTest)): """ Base class for tests that use the ISISIndirectDiffractionReduction algorithm. """ - - __metaclass__ = ABCMeta _output_workspace = None @abstractmethod diff --git a/Testing/SystemTests/tests/analysis/LoadAndCheckBase.py b/Testing/SystemTests/tests/analysis/LoadAndCheckBase.py index 6b4205b65547..601f627e9806 100644 --- a/Testing/SystemTests/tests/analysis/LoadAndCheckBase.py +++ b/Testing/SystemTests/tests/analysis/LoadAndCheckBase.py @@ -3,16 +3,16 @@ These system tests are to verify the behaviour of the ISIS reflectometry reduction scripts """ +from __future__ import (absolute_import, division, print_function) import stresstesting from mantid.simpleapi import * import mantid.api from abc import ABCMeta, abstractmethod +from six import with_metaclass -class LoadAndCheckBase(stresstesting.MantidStressTest): - - __metaclass__ = ABCMeta # Mark as an abstract class +class LoadAndCheckBase(with_metaclass(ABCMeta, stresstesting.MantidStressTest)): __comparison_out_workspace_name = 'a_integrated' diff --git a/Testing/SystemTests/tests/analysis/LoadLotsOfInstruments.py b/Testing/SystemTests/tests/analysis/LoadLotsOfInstruments.py index a3723d811463..9ab922ac695d 100644 --- a/Testing/SystemTests/tests/analysis/LoadLotsOfInstruments.py +++ b/Testing/SystemTests/tests/analysis/LoadLotsOfInstruments.py @@ -1,4 +1,5 @@ #pylint: disable=no-init,invalid-name,too-few-public-methods +from __future__ import (absolute_import, division, print_function) from mantid.simpleapi import * from mantid.api import FrameworkManager import os @@ -12,7 +13,7 @@ class LoadLotsOfInstruments(stresstesting.MantidStressTest): def __getDataFileList__(self): # get a list of directories to look in direc = config['instrumentDefinition.directory'] - print "Looking for instrument definition files in: %s" % direc + print("Looking for instrument definition files in: %s" % direc) cwd = os.getcwd() os.chdir(direc) myFiles = glob.glob("*Definition*.xml") @@ -27,8 +28,8 @@ def __getDataFileList__(self): def __loadAndTest__(self, filename): """Do all of the real work of loading and testing the file""" - print "----------------------------------------" - print "Loading '%s'" % filename + print("----------------------------------------") + print("Loading '%s'" % filename) wksp = LoadEmptyInstrument(filename) if wksp is None: return False @@ -38,7 +39,7 @@ def __loadAndTest__(self, filename): del wksp return False if wksp.getMemorySize() <= 0: - print "Workspace takes no memory: Memory used=" + str(wksp.getMemorySize()) + print("Workspace takes no memory: Memory used=" + str(wksp.getMemorySize())) del wksp return False @@ -55,25 +56,25 @@ def runTest(self): for filename in files: try: if not self.__loadAndTest__(filename): - print "FAILED TO LOAD '%s'" % filename + print("FAILED TO LOAD '%s'" % filename) failed.append(filename) #pylint: disable=broad-except - except Exception, e: - print "FAILED TO LOAD '%s' WITH ERROR:" % filename - print e + except Exception as e: + print("FAILED TO LOAD '%s' WITH ERROR:" % filename) + print(e) failed.append(filename) finally: # Clear everything for the next test FrameworkManager.Instance().clear() # final say on whether or not it 'worked' - print "----------------------------------------" + print("----------------------------------------") if len(failed) != 0: - print "SUMMARY OF FAILED FILES" + print("SUMMARY OF FAILED FILES") for filename in failed: - print filename + print(filename) raise RuntimeError("Failed to load %d of %d files" % (len(failed), len(files))) else: - print "Successfully loaded %d files" % len(files) - print files + print("Successfully loaded %d files" % len(files)) + print(files) diff --git a/Testing/SystemTests/tests/analysis/MDWorkspaceTests.py b/Testing/SystemTests/tests/analysis/MDWorkspaceTests.py index bb6fa5bfac19..74b8a172997f 100644 --- a/Testing/SystemTests/tests/analysis/MDWorkspaceTests.py +++ b/Testing/SystemTests/tests/analysis/MDWorkspaceTests.py @@ -4,11 +4,13 @@ file-backed MDWorkspaces. """ +from __future__ import (absolute_import, division, print_function) import stresstesting import os from mantid.simpleapi import * from mantid.api import * from mantid.kernel import * +from six.moves import range ############################################################################### @@ -25,7 +27,7 @@ def compare_binned(self, wsname): ws = mtd["test_binned"] EqualToMD(LHSWorkspace=ws, RHSWorkspace=self.original_binned, OutputWorkspace='comparison') comparison = mtd['comparison'] - for i in xrange(comparison.getNPoints()): + for i in range(comparison.getNPoints()): if not comparison.signalAt(i): raise Exception("Difference in workspace %s vs original_binned at index %d" % (wsname, i)) @@ -152,8 +154,8 @@ def runTest(self): LoadEventNexus(Filename='CNCS_7860_event.nxs', OutputWorkspace='CNCS_7860_event_NXS',CompressTolerance=0.1) - for omega in xrange(0, 5): - print "Starting omega %03d degrees" % omega + for omega in range(0, 5): + print("Starting omega %03d degrees" % omega) CreateMDWorkspace(Dimensions='3',Extents='-5,5,-5,5,-5,5',Names='Q_sample_x,Q_sample_y,Q__sample_z', Units='A,A,A',SplitInto='3',SplitThreshold='200',MaxRecursionDepth='3', MinRecursionDepth='3', OutputWorkspace='CNCS_7860_event_MD') diff --git a/Testing/SystemTests/tests/analysis/POLDICreatePeaksFromCellTest.py b/Testing/SystemTests/tests/analysis/POLDICreatePeaksFromCellTest.py index ab91209754dd..822102cb388d 100644 --- a/Testing/SystemTests/tests/analysis/POLDICreatePeaksFromCellTest.py +++ b/Testing/SystemTests/tests/analysis/POLDICreatePeaksFromCellTest.py @@ -1,4 +1,5 @@ # pylint: disable=no-init,invalid-name,too-many-locals,too-few-public-methods +from __future__ import (absolute_import, division, print_function) import stresstesting from mantid.simpleapi import * @@ -41,11 +42,11 @@ def checkReflections(self, peakTable, data, structureFactorPrecision = 1e-5): currentPeak = peakTable.row(idx) - self.assertEquals([int(x) for x in currentPeak['HKL'].split()], reference[0]) + self.assertEqual([int(x) for x in currentPeak['HKL'].split()], reference[0]) self.assertDelta(float(currentPeak['d']), reference[1], 1e-4) fSquaredReference = reference[2] ** 2 * reference[3] - print reference[0], fSquaredReference, float(currentPeak['Intensity']) + print(reference[0], fSquaredReference, float(currentPeak['Intensity'])) self.assertDelta(float(currentPeak['Intensity']) / fSquaredReference, 1.0, structureFactorPrecision) @@ -67,7 +68,7 @@ def runTest(self): Atoms="Si 0.4723 0.0 2/3 1.0 0.0075; O 0.416 0.2658 0.7881 1.0 0.0175", a=4.91427, c=5.4058, LatticeSpacingMin=0.885) - self.assertEquals(peaks_SiO2.rowCount(), 118) + self.assertEqual(peaks_SiO2.rowCount(), 118) self.checkReflections(peaks_SiO2, self.data) @@ -89,7 +90,7 @@ def runTest(self): Atoms="Al 0 0 0.35216 1.0 0.009; O 0.30668 0 1/4 1.0 0.0125", a=4.7605, c=12.9956, LatticeSpacingMin=0.885) - self.assertEquals(peaks_Al2O3.rowCount(), 44) + self.assertEqual(peaks_Al2O3.rowCount(), 44) self.checkReflections(peaks_Al2O3, self.data) @@ -113,7 +114,7 @@ def runTest(self): Atoms="Fe 0 0 0.35543 1.0 0.005; Zr 0 0 0.14643 1.0 0.004; O 0.31717 0.02351 0.24498 1.0 0.006", a=5.0881, c=14.091, LatticeSpacingMin=0.885) - self.assertEquals(peaks_FeTiO3.rowCount(), 108) + self.assertEqual(peaks_FeTiO3.rowCount(), 108) self.checkReflections(peaks_FeTiO3, self.data, 6e-5) @@ -137,7 +138,7 @@ def runTest(self): Atoms="C -0.042 -0.042 -0.042 1.0 0.0125; O 0.067 0.067 0.067 1.0 0.0125", a=5.63, LatticeSpacingMin=0.885) - self.assertEquals(peaks_CO.rowCount(), 91) + self.assertEqual(peaks_CO.rowCount(), 91) self.checkReflections(peaks_CO, self.data, 1e-5) @@ -161,6 +162,6 @@ def runTest(self): Atoms="Si 1/2 0 0 1.0 0.025; O 0.41570 0.20785 1/6 1.0 0.058", a=4.9965, c=5.4546, LatticeSpacingMin=0.885) - self.assertEquals(peaks_betaSiO2.rowCount(), 65) + self.assertEqual(peaks_betaSiO2.rowCount(), 65) self.checkReflections(peaks_betaSiO2, self.data, 1e-5) diff --git a/Testing/SystemTests/tests/analysis/POLDIFitPeaks1DTest.py b/Testing/SystemTests/tests/analysis/POLDIFitPeaks1DTest.py index 3185b4eef9c3..0ae7306158d0 100644 --- a/Testing/SystemTests/tests/analysis/POLDIFitPeaks1DTest.py +++ b/Testing/SystemTests/tests/analysis/POLDIFitPeaks1DTest.py @@ -1,4 +1,5 @@ #pylint: disable=no-init +from __future__ import (absolute_import, division, print_function) import stresstesting from mantid.simpleapi import * import numpy as np @@ -78,7 +79,7 @@ def analyseResults(self, filenames, versions): position = [positions[i], positionErrors[i]] fwhm = [fwhms[i], fwhmErrors[i]] - print position, fwhm, referencePositions + print(position, fwhm, referencePositions) self.assertTrue(self.positionAcceptable(position)) self.assertTrue(self.fwhmAcceptable(fwhm)) diff --git a/Testing/SystemTests/tests/analysis/POLDIFitPeaks2DTest.py b/Testing/SystemTests/tests/analysis/POLDIFitPeaks2DTest.py index 9d06bff33006..d410f025e668 100644 --- a/Testing/SystemTests/tests/analysis/POLDIFitPeaks2DTest.py +++ b/Testing/SystemTests/tests/analysis/POLDIFitPeaks2DTest.py @@ -1,4 +1,5 @@ # pylint: disable=no-init,invalid-name,too-many-locals,too-few-public-methods +from __future__ import (absolute_import, division, print_function) import stresstesting from mantid.simpleapi import * import numpy as np @@ -57,7 +58,7 @@ def analyseResults(self, filenames): columns = ["d", "Intensity"] - print fittedPeaks.rowCount(), referencePeaks.rowCount() + print(fittedPeaks.rowCount(), referencePeaks.rowCount()) for i in range(referencePeaks.rowCount()): referenceRow = referencePeaks.row(i) @@ -104,7 +105,7 @@ def runTest(self): MaximumIterations=100) # parameters a and ZeroShift - self.assertEquals(cell.rowCount(), 2) + self.assertEqual(cell.rowCount(), 2) cell_a = cell.cell(0, 1) cell_a_err = cell.cell(0, 2) @@ -139,7 +140,7 @@ def runTest(self): OutputIntegratedIntensities=True, MaximumIterations=100) - self.assertEquals(peaks_ref_2d.rowCount(), peaks_ref_2d_integrated.rowCount()) + self.assertEqual(peaks_ref_2d.rowCount(), peaks_ref_2d_integrated.rowCount()) for i in range(peaks_ref_2d.rowCount()): rowHeight = peaks_ref_2d.row(i) diff --git a/Testing/SystemTests/tests/analysis/Peak2ConvCell_Test.py b/Testing/SystemTests/tests/analysis/Peak2ConvCell_Test.py index 7e7ab7cea60c..6ae9aadd202d 100644 --- a/Testing/SystemTests/tests/analysis/Peak2ConvCell_Test.py +++ b/Testing/SystemTests/tests/analysis/Peak2ConvCell_Test.py @@ -9,6 +9,7 @@ # import stresstesting +from __future__ import (absolute_import, division, print_function) import numpy from numpy import matrix import math @@ -396,13 +397,13 @@ def FixUpPlusMinus(self, UB): # TODO make increasing lengthed sides too def FixUB(self, UB, tolerance): done = 1 - print "A" + print("A") while done == 1: done = 0 X = UB.T * UB #X.I - print "B1", X + print("B1", X) if X[0, 0] > X[1, 1] or (math.fabs(X[0, 0] - X[1, 1]) < tolerance / 10 and math.fabs(X[1, 2]) > math.fabs( X[0, 2]) + tolerance / 10): done = 1 @@ -410,10 +411,10 @@ def FixUB(self, UB, tolerance): sav = UB[i, 0] UB[i, 0] = UB[i, 1] UB[i, 1] = sav - print "B" + print("B") continue - print "B2" + print("B2") if X[1, 1] > X[2, 2] or (math.fabs(X[1, 1] - X[2, 2]) < tolerance and math.fabs(X[1, 0]) < math.fabs( X[2, 0]) - tolerance / 10): done = 1 @@ -422,18 +423,18 @@ def FixUB(self, UB, tolerance): UB[i, 1] = UB[i, 2] UB[i, 2] = sav - print "C" + print("C") continue - print "B3" + print("B3") if numpy.linalg.det(UB) < 0: for i in range(0, 3): UB[i, 0] = -1 * UB[i, 0] - print "D" + print("D") done = 1 continue - print "E" + print("E") L = [X[0, 1], X[0, 2], X[1, 2]] nneg = 0 @@ -467,12 +468,12 @@ def FixUB(self, UB, tolerance): odd = 2 - odd i1 = (odd + 1) % 3 i2 = (odd + 2) % 3 - print ["L=", L, odd, i1, i2, is90, tolerance] - print UB + print(["L=", L, odd, i1, i2, is90, tolerance]) + print(UB) for i in range(0, 3): UB[i, i1] = -1 * UB[i, i1] UB[i, i2] = -1 * UB[i, i2] - print UB + print(UB) done = 1 return UB @@ -770,7 +771,7 @@ def GetConvCell(self, Peaks, XtalCenter1, wsName, nOrigIndexed, tolerance, match OrLat = mtd["Temp"].sample().getOrientedLattice() Lat1 = [OrLat.a(), OrLat.b(), OrLat.c(), OrLat.alpha(), OrLat.beta(), OrLat.gamma()] Lat1 = self.FixLatParams(Lat1) - print ["Formnum,Lat1,Lat0", FormXtal[i1], Lat1, Lat0] + print(["Formnum,Lat1,Lat0", FormXtal[i1], Lat1, Lat0]) if math.fabs(Lat0[0] - Lat1[0]) < tolerance and math.fabs(Lat0[1] - Lat1[1]) < tolerance \ and math.fabs(Lat0[2] - Lat1[2]) < tolerance: @@ -828,10 +829,10 @@ def runTest(self): for i1 in range(3): for i2a in range(1, 3): if self.newSetting(side1, side2, Xtal, Center, ang, i1, i2a): - print "=============================================================" + print("=============================================================") Sides = [startA, startA * side1Ratios[side1], startA * side1Ratios[side2]] Sides = self.MonoClinicRearrange(Sides, Xtal, Center, i1, i2a) - print [Sides, Error, Xtal, Center, ang, i1, i2a] + print([Sides, Error, Xtal, Center, ang, i1, i2a]) UBconv = self.CalcConventionalUB(Sides[0], Sides[1], Sides[2], ang, ang, ang, Xtal) @@ -853,7 +854,7 @@ def runTest(self): Lat0 = self.getLat(UBnig) Lat0 = self.FixLatParams(Lat0) - print ["UBnig", UBnig, Lat0] + print(["UBnig", UBnig, Lat0]) Peaks = self.getPeaks(Inst, UBnig, Error, Npeaks + Error * 300) @@ -893,8 +894,8 @@ def runTest(self): Lat1 = self.FixLatParams(Lat1) MatchXtalTol = .03 * (1 + 4 * Error) * (side1Ratios[side2]) - print Lat0 - print Lat1 + print(Lat0) + print(Lat1) self.MatchXtlparams(Lat1, Lat0, MatchXtalTol, "Niggli values do not match") # Now see if the conventional cell is in list diff --git a/Testing/SystemTests/tests/analysis/PowderDiffProfileCalibrateTest.py b/Testing/SystemTests/tests/analysis/PowderDiffProfileCalibrateTest.py index cba9eb3f6674..094a4cc4694f 100644 --- a/Testing/SystemTests/tests/analysis/PowderDiffProfileCalibrateTest.py +++ b/Testing/SystemTests/tests/analysis/PowderDiffProfileCalibrateTest.py @@ -8,6 +8,7 @@ # for powder diffractometers. # ######################################################################## +from __future__ import (absolute_import, division, print_function) import stresstesting import mantid.simpleapi as api from mantid.simpleapi import * @@ -85,7 +86,7 @@ def runTest(self): ws = mtd[bkgdtablewsname] ws.addColumn("str", "Name") ws.addColumn("double", "Value") - for i in xrange(len(paramnames)): + for i in range(len(paramnames)): ws.addRow([paramnames[i], paramvalues[i]]) # Examine profile diff --git a/Testing/SystemTests/tests/analysis/ReflectometryISIS.py b/Testing/SystemTests/tests/analysis/ReflectometryISIS.py index 4a6787a0eb4e..15128ce306e3 100644 --- a/Testing/SystemTests/tests/analysis/ReflectometryISIS.py +++ b/Testing/SystemTests/tests/analysis/ReflectometryISIS.py @@ -3,15 +3,15 @@ These system tests are to verify the behaviour of the ISIS reflectometry reduction scripts """ +from __future__ import (absolute_import, division, print_function) import stresstesting from mantid.simpleapi import * from abc import ABCMeta, abstractmethod +from six import with_metaclass -class ReflectometryISIS(stresstesting.MantidStressTest): - - __metaclass__ = ABCMeta # Mark as an abstract class +class ReflectometryISIS(with_metaclass(ABCMeta, stresstesting.MantidStressTest)): @abstractmethod def get_workspace_name(self): diff --git a/Testing/SystemTests/tests/analysis/ReuseExistingCalibration.py b/Testing/SystemTests/tests/analysis/ReuseExistingCalibration.py index 2bdde8924ee1..0607db21febf 100644 --- a/Testing/SystemTests/tests/analysis/ReuseExistingCalibration.py +++ b/Testing/SystemTests/tests/analysis/ReuseExistingCalibration.py @@ -3,6 +3,7 @@ Verifies that a calibration file can be loaded once and reused to apply, using CopyInstrumentParameters, the same calibration in successive reductions. """ +from __future__ import (absolute_import, division, print_function) import stresstesting @@ -36,5 +37,5 @@ def validate(self): if self.det_pos_second_run == self.det_pos_first_run: return True else: - print "Error: Detector position is not the same after the second reduction!" + print("Error: Detector position is not the same after the second reduction!") return False diff --git a/Testing/SystemTests/tests/analysis/SANS2DMultiPeriodAddFilesTest_V2.py b/Testing/SystemTests/tests/analysis/SANS2DMultiPeriodAddFilesTest_V2.py index 3a614906d754..edec299b7308 100644 --- a/Testing/SystemTests/tests/analysis/SANS2DMultiPeriodAddFilesTest_V2.py +++ b/Testing/SystemTests/tests/analysis/SANS2DMultiPeriodAddFilesTest_V2.py @@ -1,5 +1,6 @@ -#pylint: disable=no-init +#pylint: disable=no-init +from __future__ import (absolute_import, division, print_function) from __future__ import (absolute_import, division, print_function) import stresstesting import os diff --git a/Testing/SystemTests/tests/analysis/SEQUOIAreduction.py b/Testing/SystemTests/tests/analysis/SEQUOIAreduction.py index 9938da56bcda..618f003fc05d 100644 --- a/Testing/SystemTests/tests/analysis/SEQUOIAreduction.py +++ b/Testing/SystemTests/tests/analysis/SEQUOIAreduction.py @@ -3,6 +3,7 @@ Test the SNS inelatic reduction scripts. """ +from __future__ import (absolute_import, division, print_function) import stresstesting import os import shutil @@ -68,19 +69,19 @@ def createanglelist(self,ws,angmin,angmax,angstep): ang_list.append(ang) # file with grouping information f = open(os.path.join(self.customDataDir,"group.map"),'w') - print >>f,len(ang_list) + print(len(ang_list), file=f) for i in range(len(ang_list)): - print >>f,i - print >>f,len(detIDlist[i]) + print(i, file=f) + print(len(detIDlist[i]), file=f) mystring=str(detIDlist[i]).strip(']').strip('[') mystring=mystring.replace(',','') - print >>f,mystring + print(mystring, file=f) f.close() # par file f = open(os.path.join(self.customDataDir,"group.par"),'w') - print >>f,len(ang_list) + print(len(ang_list), file=f) for angi in ang_list: - print >>f,5.5,angi,0.0,1.0,1.0,1 + print(5.5,angi,0.0,1.0,1.0,1, file=f) f.close() return [ang_list,detIDlist] @@ -244,7 +245,7 @@ def validate(self): #find the nxspe filename: it should be only one, but the name might depend on the rounding of phi nxspelist=glob.glob(os.path.join(self.customDataDir,'*.nxspe')) if len(nxspelist)>1 or len(nxspelist) == 0: - print "Error: Expected single nxspe file in %s. Found %d" % (self.customDataDir, len(nxspelist)) + print("Error: Expected single nxspe file in %s. Found %d" % (self.customDataDir, len(nxspelist))) return False # Name encodes rotation diff --git a/Testing/SystemTests/tests/analysis/SNSConvertToMDTest.py b/Testing/SystemTests/tests/analysis/SNSConvertToMDTest.py index f34b6f17ad29..1e5e546227b3 100644 --- a/Testing/SystemTests/tests/analysis/SNSConvertToMDTest.py +++ b/Testing/SystemTests/tests/analysis/SNSConvertToMDTest.py @@ -1,4 +1,5 @@ #pylint: disable=invalid-name,no-init +from __future__ import (absolute_import, division, print_function) import stresstesting from mantid.simpleapi import * @@ -98,8 +99,8 @@ def validateMD(result,reference,tol=1.e-5,class_name='dummy',mismatchName=None): checker.execute() if checker.getPropertyValue("Equals") != "1": - print " Workspaces do not match, result: ",checker.getPropertyValue("Result") - print " Test {0} fails".format(class_name) + print(" Workspaces do not match, result: ",checker.getPropertyValue("Result")) + print(" Test {0} fails".format(class_name)) if mismatchName: targetFilename = class_name+mismatchName+'-mismatch.nxs' else: diff --git a/Testing/SystemTests/tests/analysis/SXDAnalysis.py b/Testing/SystemTests/tests/analysis/SXDAnalysis.py index b4ef6ec64c25..c44058a458df 100644 --- a/Testing/SystemTests/tests/analysis/SXDAnalysis.py +++ b/Testing/SystemTests/tests/analysis/SXDAnalysis.py @@ -1,4 +1,5 @@ #pylint: disable=no-init,invalid-name +from __future__ import (absolute_import, division, print_function) import stresstesting from mantid.simpleapi import * @@ -19,7 +20,7 @@ def runTest(self): QLab = ConvertToDiffractionMDWorkspace(InputWorkspace=ws, OutputDimensions='Q (lab frame)', SplitThreshold=50, LorentzCorrection='1',MaxRecursionDepth='13', Extents='-15,15,-15,15,-15,15',OneEventPerBin='0') - print " ConvertToMD runs for: ",clock()-start,' sec' + print(" ConvertToMD runs for: ",clock()-start,' sec') # NaCl has a relatively small unit cell, so the distance between peaks is relatively large. Setting the PeakDistanceThreshold # higher avoids finding high count regions on the sides of strong peaks as separate peaks. diff --git a/Testing/SystemTests/tests/analysis/SortHKLTest.py b/Testing/SystemTests/tests/analysis/SortHKLTest.py index 1791db2de5d6..31618635e176 100644 --- a/Testing/SystemTests/tests/analysis/SortHKLTest.py +++ b/Testing/SystemTests/tests/analysis/SortHKLTest.py @@ -1,8 +1,10 @@ # pylint: disable=no-init,attribute-defined-outside-init +from __future__ import (absolute_import, division, print_function) import stresstesting import json from mantid.simpleapi import * from mantid.geometry import PointGroupFactory +from six import iteritems class HKLStatisticsTestMixin(object): @@ -35,7 +37,7 @@ def _load_ub_parameters(self, space_group): ub_parameters.update( dict( [(str(x), y if isinstance(y, float) else str(y)) - for x, y in raw_ub_parameters.iteritems()] + for x, y in iteritems(raw_ub_parameters)] )) return ub_parameters @@ -69,7 +71,7 @@ def _load_reference_statistics(self, space_group): keys = lines[0].split() values = [float(x) for x in lines[2].split()[2:]] - overall_statistics = dict(zip(keys, values)) + overall_statistics = dict(list(zip(keys, values))) completentess = float(lines[3].split()[-1].replace('%', '')) overall_statistics['Completeness'] = completentess @@ -121,9 +123,9 @@ def _run_sort_hkl(self, reflections, space_group): return statistics.row(0), sorted_hkls def _compare_statistics(self, statistics, reference_statistics): - self.assertEquals(round(statistics['Multiplicity'], 1), round(reference_statistics[''], 1)) - self.assertEquals(round(statistics['Rpim'], 2), round(100.0 * reference_statistics['Rm'], 2)) - self.assertEquals(statistics['No. of Unique Reflections'], int(reference_statistics['Nunique'])) + self.assertEqual(round(statistics['Multiplicity'], 1), round(reference_statistics[''], 1)) + self.assertEqual(round(statistics['Rpim'], 2), round(100.0 * reference_statistics['Rm'], 2)) + self.assertEqual(statistics['No. of Unique Reflections'], int(reference_statistics['Nunique'])) self.assertDelta(round(statistics['Data Completeness'], 1), round(reference_statistics['Completeness'], 1), 0.5) @@ -141,9 +143,9 @@ def _check_sorted_hkls_consistency(self, sorted_hkls, space_group): unique_map[unique].append(peak) # pylint: disable=unused-variable - for unique_hkl, equivalents in unique_map.iteritems(): + for unique_hkl, equivalents in iteritems(unique_map): if len(equivalents) > 1: reference_peak = equivalents[0] for peak in equivalents[1:]: - self.assertEquals(peak.getIntensity(), reference_peak.getIntensity()) - self.assertEquals(peak.getSigmaIntensity(), reference_peak.getSigmaIntensity()) + self.assertEqual(peak.getIntensity(), reference_peak.getIntensity()) + self.assertEqual(peak.getSigmaIntensity(), reference_peak.getSigmaIntensity()) diff --git a/Testing/SystemTests/tests/analysis/SpaceGroupFactoryTest.py b/Testing/SystemTests/tests/analysis/SpaceGroupFactoryTest.py index 76887caca0c4..b988bfdb59c8 100644 --- a/Testing/SystemTests/tests/analysis/SpaceGroupFactoryTest.py +++ b/Testing/SystemTests/tests/analysis/SpaceGroupFactoryTest.py @@ -1,4 +1,5 @@ # pylint: disable=no-init +from __future__ import (absolute_import, division, print_function) import stresstesting import re from mantid.simpleapi import * @@ -81,7 +82,7 @@ def loadReferenceData(self): if matchedSeparator is not None: currentGroup = matchedSeparator.group(1) - print currentGroup + print(currentGroup) spaceGroups[currentGroup] = set() else: diff --git a/Testing/SystemTests/tests/analysis/SpaceGroupReflectionConditionsTest.py b/Testing/SystemTests/tests/analysis/SpaceGroupReflectionConditionsTest.py index 1003b139ec02..5deddf31ff2a 100644 --- a/Testing/SystemTests/tests/analysis/SpaceGroupReflectionConditionsTest.py +++ b/Testing/SystemTests/tests/analysis/SpaceGroupReflectionConditionsTest.py @@ -1,7 +1,9 @@ # pylint: disable=no-init,invalid-name +from __future__ import (absolute_import, division, print_function) import stresstesting from mantid.simpleapi import * from mantid.geometry import * +from six import iteritems class SpaceGroupReflectionConditionsTest(stresstesting.MantidStressTest): @@ -18,7 +20,7 @@ class SpaceGroupReflectionConditionsTest(stresstesting.MantidStressTest): def runTest(self): sgTestDict = self.generateReflectionLists() - for sgName, hkls in sgTestDict.iteritems(): + for sgName, hkls in iteritems(sgTestDict): sg = SpaceGroupFactory.createSpaceGroup(sgName) for hkl in hkls: @@ -47,6 +49,6 @@ def generateReflectionLists(self): hkls = [[int(m) for m in x.split()] for x in reflectionsWs.column(0)] sgDict[sg] = hkls except ValueError: - print sg + print(sg) return sgDict diff --git a/Testing/SystemTests/tests/analysis/SpaceGroupUnitCellTest.py b/Testing/SystemTests/tests/analysis/SpaceGroupUnitCellTest.py index 9eef21ac44eb..911809824454 100644 --- a/Testing/SystemTests/tests/analysis/SpaceGroupUnitCellTest.py +++ b/Testing/SystemTests/tests/analysis/SpaceGroupUnitCellTest.py @@ -1,6 +1,8 @@ # pylint: disable=no-init,invalid-name +from __future__ import (absolute_import, division, print_function) import stresstesting from mantid.geometry import * +from six import iteritems class SpaceGroupUnitCellTest(stresstesting.MantidStressTest): @@ -32,7 +34,7 @@ def runTest(self): self._check_spacegroup(sg, monoclinic_c_cells, monoclinic_c_compatiblity[lattice_system]) def _check_spacegroup(self, sg, cells, compatible_metrics): - for system, cell in cells.iteritems(): + for system, cell in iteritems(cells): is_allowed = sg.isAllowedUnitCell(cell) should_be_allowed = system in compatible_metrics @@ -56,7 +58,7 @@ def getMetricCompatibility(self, cells): # This map specifies which metrics are compatible. A cell with cubic metric is for example compatible # with triclinic symmetry, but the opposite is not true. return { - PointGroup.LatticeSystem.Triclinic: cells.keys(), + PointGroup.LatticeSystem.Triclinic: list(cells.keys()), PointGroup.LatticeSystem.Monoclinic: [PointGroup.LatticeSystem.Monoclinic, PointGroup.LatticeSystem.Orthorhombic, PointGroup.LatticeSystem.Tetragonal, diff --git a/Testing/SystemTests/tests/analysis/SphinxWarnings.py b/Testing/SystemTests/tests/analysis/SphinxWarnings.py index b31e535a9cb4..1f2e55cacdd7 100644 --- a/Testing/SystemTests/tests/analysis/SphinxWarnings.py +++ b/Testing/SystemTests/tests/analysis/SphinxWarnings.py @@ -4,9 +4,11 @@ This test tries to detect the most common such errors. It also detects if a new category is created (i.e. someone uses Utilities instead of Utility) """ +from __future__ import (absolute_import, division, print_function) import stresstesting import mantid import re +from six import iteritems class SphinxWarnings(stresstesting.MantidStressTest): @@ -80,7 +82,7 @@ def checkString(self,s): def runTest(self): algs = mantid.AlgorithmFactory.getRegisteredAlgorithms(True) - for (name, versions) in algs.iteritems(): + for (name, versions) in iteritems(algs): for version in versions: if mantid.api.DeprecatedAlgorithmChecker(name,version).isDeprecated()=='': # get an instance @@ -106,7 +108,7 @@ def runTest(self): def validate(self): if self.errorMessage!="": - print "Found the following errors:\n",self.errorMessage + print("Found the following errors:\n",self.errorMessage) return False return True diff --git a/Testing/SystemTests/tests/analysis/SurfLoadingTest.py b/Testing/SystemTests/tests/analysis/SurfLoadingTest.py index f30fbc827548..6ebd641b0f57 100644 --- a/Testing/SystemTests/tests/analysis/SurfLoadingTest.py +++ b/Testing/SystemTests/tests/analysis/SurfLoadingTest.py @@ -1,4 +1,5 @@ #pylint: disable=no-init +from __future__ import (absolute_import, division, print_function) from LoadAndCheckBase import * diff --git a/Testing/SystemTests/tests/analysis/TOPAZPeakFinding.py b/Testing/SystemTests/tests/analysis/TOPAZPeakFinding.py index 7e69865f5d4c..73cdf6b3df95 100644 --- a/Testing/SystemTests/tests/analysis/TOPAZPeakFinding.py +++ b/Testing/SystemTests/tests/analysis/TOPAZPeakFinding.py @@ -4,6 +4,7 @@ converts to Q space, finds peaks and indexes them. """ +from __future__ import (absolute_import, division, print_function) import stresstesting import numpy from mantid.simpleapi import * @@ -91,7 +92,7 @@ def runTest(self): newUB = numpy.array(mtd["topaz_3132"].sample().getOrientedLattice().getUB()) # UB Matrices are not necessarily the same, some of the H,K and/or L sign can be reversed diff = abs(newUB) - abs(originalUB) < 0.001 - for c in xrange(3): + for c in range(3): # This compares each column, allowing old == new OR old == -new if not numpy.all(diff[:,c]) : raise Exception("More than 0.001 difference between UB matrices: Q (lab frame):\n" diff --git a/Testing/SystemTests/tests/analysis/ValidateFacilitiesFile.py b/Testing/SystemTests/tests/analysis/ValidateFacilitiesFile.py index 9220c37a17b9..0164a32b2b77 100644 --- a/Testing/SystemTests/tests/analysis/ValidateFacilitiesFile.py +++ b/Testing/SystemTests/tests/analysis/ValidateFacilitiesFile.py @@ -1,4 +1,5 @@ #pylint: disable=no-init,invalid-name +from __future__ import (absolute_import, division, print_function) from mantid import config import os import stresstesting @@ -26,18 +27,18 @@ def runTest(self): # run the tests failed = [] try: - print "----------------------------------------" - print "Validating Facilities.xml" + print("----------------------------------------") + print("Validating Facilities.xml") pyxsval.parseAndValidateXmlInput(filename, xsdFile=xsdFile, validateSchema=0) - except Exception, e: - print "VALIDATION OF Facilities.xml FAILED WITH ERROR:" - print e + except Exception as e: + print("VALIDATION OF Facilities.xml FAILED WITH ERROR:") + print(e) failed.append(filename) # final say on whether or not it 'worked' - print "----------------------------------------" + print("----------------------------------------") if len(failed) != 0: - print "SUMMARY OF FAILED FILES" + print("SUMMARY OF FAILED FILES") raise RuntimeError("Failed Validation of Facilities.xml") else: - print "Succesfully Validated Facilities.xml" + print("Succesfully Validated Facilities.xml") diff --git a/Testing/SystemTests/tests/analysis/ValidateGroupingFiles.py b/Testing/SystemTests/tests/analysis/ValidateGroupingFiles.py index 70de8fc38457..6f6259b260a7 100644 --- a/Testing/SystemTests/tests/analysis/ValidateGroupingFiles.py +++ b/Testing/SystemTests/tests/analysis/ValidateGroupingFiles.py @@ -1,4 +1,5 @@ #pylint: disable=no-init +from __future__ import (absolute_import, division, print_function) from mantid import config import os import stresstesting @@ -22,7 +23,7 @@ def __getDataFileList__(self): # get a list of directories to look in direc = config['instrumentDefinition.directory'] direc = os.path.join(direc,'Grouping') - print "Looking for Grouping files in: %s" % direc + print("Looking for Grouping files in: %s" % direc) cwd = os.getcwd() os.chdir(direc) myFiles = glob.glob("*Grouping*.xml") @@ -43,21 +44,21 @@ def runTest(self): failed = [] for filename in files: try: - print "----------------------------------------" - print "Validating '%s'" % filename + print("----------------------------------------") + print("Validating '%s'" % filename) pyxsval.parseAndValidateXmlInput(filename, xsdFile=self.xsdFile, validateSchema=0) - except Exception, err: - print "VALIDATION OF '%s' FAILED WITH ERROR:" % filename - print err + except Exception as err: + print("VALIDATION OF '%s' FAILED WITH ERROR:" % filename) + print(err) failed.append(filename) # final say on whether or not it 'worked' - print "----------------------------------------" + print("----------------------------------------") if len(failed) != 0: - print "SUMMARY OF FAILED FILES" + print("SUMMARY OF FAILED FILES") for filename in failed: - print filename + print(filename) raise RuntimeError("Failed Validation for %d of %d files" % (len(failed), len(files))) else: - print "Succesfully Validated %d files" % len(files) + print("Succesfully Validated %d files" % len(files)) diff --git a/Testing/SystemTests/tests/analysis/ValidateInstrumentDefinitionFiles.py b/Testing/SystemTests/tests/analysis/ValidateInstrumentDefinitionFiles.py index ba4704aa4338..eca88a957be6 100644 --- a/Testing/SystemTests/tests/analysis/ValidateInstrumentDefinitionFiles.py +++ b/Testing/SystemTests/tests/analysis/ValidateInstrumentDefinitionFiles.py @@ -1,5 +1,6 @@ #pylint: disable=invalid-name #pylint: disable=no-init +from __future__ import (absolute_import, division, print_function) from mantid import config import os import stresstesting @@ -26,7 +27,7 @@ def skipTests(self): def __getDataFileList__(self): # get a list of directories to look in direc = config['instrumentDefinition.directory'] - print "Looking for instrument definition files in: %s" % direc + print("Looking for instrument definition files in: %s" % direc) cwd = os.getcwd() os.chdir(direc) myFiles = glob.glob("*Definition*.xml") @@ -78,24 +79,24 @@ def parseAndValidateXmlInputForceReadFile(inputFile, xsdFile=None, **kw): failed = [] for filename in files: try: - print "----------------------------------------" - print "Validating '%s'" % filename + print("----------------------------------------") + print("Validating '%s'" % filename) parseAndValidateXmlInputForceReadFile(filename, xsdFile=self.xsdFile) - except Exception, e: - print "VALIDATION OF '%s' FAILED WITH ERROR:" % filename - print e + except Exception as e: + print("VALIDATION OF '%s' FAILED WITH ERROR:" % filename) + print(e) failed.append(filename) # final say on whether or not it 'worked' - print "----------------------------------------" + print("----------------------------------------") if len(failed) != 0: - print "SUMMARY OF FAILED FILES" + print("SUMMARY OF FAILED FILES") for filename in failed: - print filename + print(filename) raise RuntimeError("Failed Validation for %d of %d files" % (len(failed), len(files))) else: - print "Succesfully Validated %d files" % len(files) + print("Succesfully Validated %d files" % len(files)) if __name__ == '__main__': diff --git a/Testing/SystemTests/tests/analysis/ValidateParameterFiles.py b/Testing/SystemTests/tests/analysis/ValidateParameterFiles.py index 084e52746e73..d2d0060d4506 100644 --- a/Testing/SystemTests/tests/analysis/ValidateParameterFiles.py +++ b/Testing/SystemTests/tests/analysis/ValidateParameterFiles.py @@ -1,4 +1,5 @@ #pylint: disable=no-init,invalid-name +from __future__ import (absolute_import, division, print_function) from mantid import config import os import stresstesting @@ -22,7 +23,7 @@ def skipTests(self): def __getDataFileList__(self): # get a list of directories to look in direc = config['instrumentDefinition.directory'] - print "Looking for instrument definition files in: %s" % direc + print("Looking for instrument definition files in: %s" % direc) cwd = os.getcwd() os.chdir(direc) myFiles = glob.glob("*Parameters*.xml") @@ -36,7 +37,7 @@ def runTest(self): """Main entry point for the test suite""" from minixsv import pyxsval # noqa direc = config['instrumentDefinition.directory'] - print direc + print(direc) self.xsdFile = os.path.join(direc,'Schema/ParameterFile/1.0/','ParameterFileSchema.xsd') files = self.__getDataFileList__() @@ -44,24 +45,24 @@ def runTest(self): failed = [] for filename in files: try: - print "----------------------------------------" - print "Validating '%s'" % filename + print("----------------------------------------") + print("Validating '%s'" % filename) pyxsval.parseAndValidateXmlInput(filename, xsdFile=self.xsdFile, validateSchema=0) - except Exception, e: - print "VALIDATION OF '%s' FAILED WITH ERROR:" % filename - print e + except Exception as e: + print("VALIDATION OF '%s' FAILED WITH ERROR:" % filename) + print(e) failed.append(filename) # final say on whether or not it 'worked' - print "----------------------------------------" + print("----------------------------------------") if len(failed) != 0: - print "SUMMARY OF FAILED FILES" + print("SUMMARY OF FAILED FILES") for filename in failed: - print filename + print(filename) raise RuntimeError("Failed Validation for %d of %d files" % (len(failed), len(files))) else: - print "Succesfully Validated %d files" % len(files) + print("Succesfully Validated %d files" % len(files)) if __name__ == '__main__': valid = ValidateParameterFiles() diff --git a/Testing/SystemTests/tests/analysis/WishCalibrate.py b/Testing/SystemTests/tests/analysis/WishCalibrate.py index 2ae2fb2e584a..bbafc219e0c8 100644 --- a/Testing/SystemTests/tests/analysis/WishCalibrate.py +++ b/Testing/SystemTests/tests/analysis/WishCalibrate.py @@ -1,3 +1,4 @@ +from __future__ import (absolute_import, division, print_function) import filecmp import numpy as np import os diff --git a/Testing/SystemTests/tests/analysis/WishMasking.py b/Testing/SystemTests/tests/analysis/WishMasking.py index 59bd853d6637..6b0707231e19 100644 --- a/Testing/SystemTests/tests/analysis/WishMasking.py +++ b/Testing/SystemTests/tests/analysis/WishMasking.py @@ -4,6 +4,7 @@ - Email Pascal Manuel @ ISIS if things break here and let him know how his scripts may need to be modified. """ +from __future__ import (absolute_import, division, print_function) import stresstesting import os from mantid.simpleapi import * @@ -44,7 +45,7 @@ def do_test_cal_file(self, masked_workspace, should_invert, expected_masking_ide self.assertTrue(mask_boundary_inside == expected_masking_identifier) self.assertTrue(mask_boundary_outside == expected_not_masking_identifier) except LookupError: - print "Could not find the requested index" + print("Could not find the requested index") self.assertTrue(False) finally: cfile.close()