From 7267609b7e672c5cb91cb366a4ae9c6844983053 Mon Sep 17 00:00:00 2001 From: Martyn Gigg <martyn.gigg@stfc.ac.uk> Date: Mon, 23 Dec 2019 11:09:45 +0000 Subject: [PATCH] Fix syntax warnings when comparing literals Python 3.8 warnings no using is with literal values Refs #16578 --- Framework/PythonInterface/mantid/fitfunctions.py | 2 +- .../plugins/algorithms/ConvertWANDSCDtoQ.py | 2 +- .../plugins/algorithms/HB2AReduce.py | 2 +- .../plugins/algorithms/LoadWANDSCD.py | 2 +- .../ISISIndirectDiffractionReduction.py | 2 +- .../SystemTests/lib/systemtests/systemtesting.py | 2 +- qt/python/mantidqt/project/plotsloader.py | 14 +++++++------- scripts/Inelastic/CrystalField/normalisation.py | 2 +- scripts/Inelastic/Direct/PropertiesDescriptors.py | 2 +- scripts/LargeScaleStructures/geometry_writer.py | 4 ++-- .../MaxEnt/maxent_presenter.py | 2 +- scripts/test/DirectReductionHelpersTest.py | 6 +++--- 12 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Framework/PythonInterface/mantid/fitfunctions.py b/Framework/PythonInterface/mantid/fitfunctions.py index fd53996acf8..4ac4bdbb022 100644 --- a/Framework/PythonInterface/mantid/fitfunctions.py +++ b/Framework/PythonInterface/mantid/fitfunctions.py @@ -370,7 +370,7 @@ class FunctionWrapper(object): # to pass InputWorkspace into EvaluateFunction before Function. # As a special case has been made for this. This case can be removed # with ordered kwargs change in Python 3.6. - if name is 'EvaluateFunction': + if name == 'EvaluateFunction': alg.setProperty('Function', kwargs['Function']) del kwargs['Function'] alg.setProperty('InputWorkspace', kwargs['InputWorkspace']) diff --git a/Framework/PythonInterface/plugins/algorithms/ConvertWANDSCDtoQ.py b/Framework/PythonInterface/plugins/algorithms/ConvertWANDSCDtoQ.py index ed5e07670ea..9e5bfc36877 100644 --- a/Framework/PythonInterface/plugins/algorithms/ConvertWANDSCDtoQ.py +++ b/Framework/PythonInterface/plugins/algorithms/ConvertWANDSCDtoQ.py @@ -86,7 +86,7 @@ class ConvertWANDSCDtoQ(PythonAlgorithm): d2 = inWS.getDimension(2) number_of_runs = d2.getNBins() - if (d0.name is not 'y' or d1.name is not 'x' or d2.name != 'scanIndex'): + if (d0.name != 'y' or d1.name != 'x' or d2.name != 'scanIndex'): issues["InputWorkspace"] = "InputWorkspace has wrong dimensions" return issues diff --git a/Framework/PythonInterface/plugins/algorithms/HB2AReduce.py b/Framework/PythonInterface/plugins/algorithms/HB2AReduce.py index d28ef500fdc..817d81c1860 100644 --- a/Framework/PythonInterface/plugins/algorithms/HB2AReduce.py +++ b/Framework/PythonInterface/plugins/algorithms/HB2AReduce.py @@ -78,7 +78,7 @@ class HB2AReduce(PythonAlgorithm): if not self.getProperty("Filename").value: ipts = self.getProperty("IPTS").value - if ((ipts == Property.EMPTY_INT) or len(self.getProperty("ScanNumbers").value) is 0): + if ((ipts == Property.EMPTY_INT) or len(self.getProperty("ScanNumbers").value) == 0): issues["Filename"] = 'Must specify either Filename or IPTS AND ScanNumbers' if self.getProperty("Exp").value == Property.EMPTY_INT: diff --git a/Framework/PythonInterface/plugins/algorithms/LoadWANDSCD.py b/Framework/PythonInterface/plugins/algorithms/LoadWANDSCD.py index 48877bc1139..d5280d8f583 100644 --- a/Framework/PythonInterface/plugins/algorithms/LoadWANDSCD.py +++ b/Framework/PythonInterface/plugins/algorithms/LoadWANDSCD.py @@ -43,7 +43,7 @@ class LoadWANDSCD(PythonAlgorithm): issues = dict() if not self.getProperty("Filename").value: - if (self.getProperty("IPTS").value == Property.EMPTY_INT) or len(self.getProperty("RunNumbers").value) is 0: + if (self.getProperty("IPTS").value == Property.EMPTY_INT) or len(self.getProperty("RunNumbers").value) == 0: issues["Filename"] = 'Must specify either Filename or IPTS AND RunNumbers' return issues diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ISISIndirectDiffractionReduction.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ISISIndirectDiffractionReduction.py index 9a7fc6d8ea3..f26e4a6dc15 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ISISIndirectDiffractionReduction.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ISISIndirectDiffractionReduction.py @@ -390,7 +390,7 @@ class ISISIndirectDiffractionReduction(DataProcessorAlgorithm): Checks to ensure a calibration file has been given and if so performs AlignDetectors and DiffractionFocussing. """ - if self._cal_file is not '': + if self._cal_file != '': for ws_name in self._workspace_names: AlignDetectors(InputWorkspace=ws_name, OutputWorkspace=ws_name, diff --git a/Testing/SystemTests/lib/systemtests/systemtesting.py b/Testing/SystemTests/lib/systemtests/systemtesting.py index bdc5a0c7cd8..8f5a5fe5e2e 100644 --- a/Testing/SystemTests/lib/systemtests/systemtesting.py +++ b/Testing/SystemTests/lib/systemtests/systemtesting.py @@ -1036,7 +1036,7 @@ class TestManager(object): mod_attrs = dir(mod) for key in mod_attrs: value = getattr(mod, key) - if key is "MantidSystemTest" or not inspect.isclass(value): + if key == "MantidSystemTest" or not inspect.isclass(value): continue if self.isValidTestClass(value): test_name = key diff --git a/qt/python/mantidqt/project/plotsloader.py b/qt/python/mantidqt/project/plotsloader.py index ee19bf74313..309998423ad 100644 --- a/qt/python/mantidqt/project/plotsloader.py +++ b/qt/python/mantidqt/project/plotsloader.py @@ -239,19 +239,19 @@ class PlotsLoader(object): def update_axis(self, axis_, properties): if isinstance(axis_, matplotlib.axis.XAxis): - if properties["position"] is "top": + if properties["position"] == "top": axis_.tick_top() else: axis_.tick_bottom() if isinstance(axis_, matplotlib.axis.YAxis): - if properties["position"] is "right": + if properties["position"] == "right": axis_.tick_right() else: axis_.tick_left() labels = axis_.get_ticklabels() - if properties["fontSize"] is not "": + if properties["fontSize"] != "": for label in labels: label.set_fontsize(properties["fontSize"]) @@ -276,17 +276,17 @@ class PlotsLoader(object): @staticmethod def update_axis_ticks(axis_, properties): # Update Major and Minor Locator - if properties["majorTickLocator"] is "FixedLocator": + if properties["majorTickLocator"] == "FixedLocator": axis_.set_major_locator(ticker.FixedLocator(properties["majorTickLocatorValues"])) - if properties["minorTickLocator"] is "FixedLocator": + if properties["minorTickLocator"] == "FixedLocator": axis_.set_minor_locator(ticker.FixedLocator(properties["minorTickLocatorValues"])) # Update Major and Minor Formatter - if properties["majorTickFormatter"] is "FixedFormatter": + if properties["majorTickFormatter"] == "FixedFormatter": axis_.set_major_formatter(ticker.FixedFormatter(properties["majorTickFormat"])) - if properties["minorTickFormatter"] is "FixedFormatter": + if properties["minorTickFormatter"] == "FixedFormatter": axis_.set_major_formatter(ticker.FixedLocator(properties["minorTickFormat"])) @staticmethod diff --git a/scripts/Inelastic/CrystalField/normalisation.py b/scripts/Inelastic/CrystalField/normalisation.py index 42c101bb894..89d9e25c9ff 100644 --- a/scripts/Inelastic/CrystalField/normalisation.py +++ b/scripts/Inelastic/CrystalField/normalisation.py @@ -212,7 +212,7 @@ def split2range(*args, **kwargs): Nlm[bname] = splitting_factor ranges = norm2stev(IonNum=nre, **Nlm) - if argin['Output'].lower() is 'constraints': + if argin['Output'].lower() == 'constraints': constr = '' for bname in ranges.keys(): constr += '%.4g<%s<%.4g,' % (-ranges[bname], bname, ranges[bname]) diff --git a/scripts/Inelastic/Direct/PropertiesDescriptors.py b/scripts/Inelastic/Direct/PropertiesDescriptors.py index 23d18c73955..a22e2e03799 100644 --- a/scripts/Inelastic/Direct/PropertiesDescriptors.py +++ b/scripts/Inelastic/Direct/PropertiesDescriptors.py @@ -1201,7 +1201,7 @@ class SpectraToMonitorsList(PropDescriptor): return None if isinstance(spectra_list, string_types): - if spectra_list.lower() is 'none': + if spectra_list.lower() == 'none': result = None else: spectra = spectra_list.split(',') diff --git a/scripts/LargeScaleStructures/geometry_writer.py b/scripts/LargeScaleStructures/geometry_writer.py index 031bf1bda74..a74d8f854d2 100644 --- a/scripts/LargeScaleStructures/geometry_writer.py +++ b/scripts/LargeScaleStructures/geometry_writer.py @@ -105,12 +105,12 @@ class MantidGeom(object): if location is None: self._append_child("location", sample, x="0.0", y="0.0", z="0.0") else: - if coord_type is "cartesian": + if coord_type == "cartesian": self._append_child("location", sample, x=location[0], y=location[1], z=location[2]) - if coord_type is "spherical": + if coord_type == "spherical": self._append_child("location", sample, r=location[0], t=location[1], diff --git a/scripts/Muon/GUI/FrequencyDomainAnalysis/MaxEnt/maxent_presenter.py b/scripts/Muon/GUI/FrequencyDomainAnalysis/MaxEnt/maxent_presenter.py index 4429ca99e33..e7a06d561ad 100644 --- a/scripts/Muon/GUI/FrequencyDomainAnalysis/MaxEnt/maxent_presenter.py +++ b/scripts/Muon/GUI/FrequencyDomainAnalysis/MaxEnt/maxent_presenter.py @@ -54,7 +54,7 @@ class MaxEntPresenter(object): else: self.view.setRun("") - if run is not "None": + if run != "None": final_options.append(run) self.view.addItems(final_options) start = int( diff --git a/scripts/test/DirectReductionHelpersTest.py b/scripts/test/DirectReductionHelpersTest.py index 6ab18eb09f3..13fa61a6b0c 100644 --- a/scripts/test/DirectReductionHelpersTest.py +++ b/scripts/test/DirectReductionHelpersTest.py @@ -290,7 +290,7 @@ class DirectReductionHelpersTest(unittest.TestCase): return attr else: attr_dic = object.__getattribute__(self,'__dict__') - if name is '__dict__': + if name == '__dict__': return attr_dic else: return helpers.gen_getter(attr_dic,name) @@ -346,7 +346,7 @@ class DirectReductionHelpersTest(unittest.TestCase): some_descriptor = SomeDescriptor() def __setattr__(self,name,val): - if name is 'special': + if name == 'special': return elif name in self.__class__.__dict__: fp = self.__class__.__dict__[name] @@ -356,7 +356,7 @@ class DirectReductionHelpersTest(unittest.TestCase): def __getattr__(self,name): - if name is 'special': + if name == 'special': return self.__special else: tDict = object.__getattribute__(self,'__dict__') -- GitLab