From 6e521e1a472e1dbcd6874079d3e791129587518b Mon Sep 17 00:00:00 2001 From: Thomas Fillon Date: Tue, 22 Apr 2014 15:49:16 +0200 Subject: [PATCH] Fix several PEP8 warnings --- timeside/component.py | 4 ++-- timeside/core.py | 4 ++-- timeside/exceptions.py | 2 +- timeside/grapher/core.py | 2 +- timeside/grapher/utils.py | 6 +++--- timeside/tools/cache.py | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/timeside/component.py b/timeside/component.py index 7f72852..a92ae16 100644 --- a/timeside/component.py +++ b/timeside/component.py @@ -99,8 +99,8 @@ class MetaComponent(type): for i in MetaComponent.implements: MetaComponent.implementations.append({ 'interface': i, - 'class': new_class, - 'abstract': MetaComponent.abstract}) + 'class': new_class, + 'abstract': MetaComponent.abstract}) # Propagate @interfacedoc for name in new_class.__dict__: diff --git a/timeside/core.py b/timeside/core.py index 6ef34f4..0d68cc7 100644 --- a/timeside/core.py +++ b/timeside/core.py @@ -49,7 +49,7 @@ class MetaProcessor(MetaComponent): new_class = MetaComponent.__new__(cls, name, bases, d) if new_class in implementations(IProcessor): id = str(new_class.id()) - if _processors.has_key(id): + if id in _processors: # Doctest test can duplicate a processor # This can be identify by the conditon "module == '__main__'" if new_class.__module__ == '__main__': @@ -229,7 +229,7 @@ def processors(interface=IProcessor, recurse=True): def get_processor(processor_id): """Return a processor by its id""" - if not _processors.has_key(processor_id): + if not processor_id in _processors: raise Error("No processor registered with id: '%s'" % processor_id) diff --git a/timeside/exceptions.py b/timeside/exceptions.py index 09a9fa2..3f36990 100644 --- a/timeside/exceptions.py +++ b/timeside/exceptions.py @@ -38,7 +38,7 @@ class SubProcessError(Error): self.subprocess = subprocess def __str__(self): - if self.subprocess.stderr != None: + if self.subprocess.stderr is not None: error = self.subprocess.stderr.read() else: error = '' diff --git a/timeside/grapher/core.py b/timeside/grapher/core.py index 8708827..a77596e 100644 --- a/timeside/grapher/core.py +++ b/timeside/grapher/core.py @@ -102,7 +102,7 @@ class Spectrum(object): if energy > 1e-20: # calculate the spectral centroid - if self.spectrum_range == None: + if self.spectrum_range is None: self.spectrum_range = numpy.arange(length) spectral_centroid = (spectrum * self.spectrum_range).sum() / \ (energy * (length - 1)) * \ diff --git a/timeside/grapher/utils.py b/timeside/grapher/utils.py index e3c525c..3dc6227 100644 --- a/timeside/grapher/utils.py +++ b/timeside/grapher/utils.py @@ -134,13 +134,13 @@ def smooth(x, window_len=10, window='hanning'): # instead of a string if x.ndim != 1: - raise ValueError, "smooth only accepts 1 dimension arrays." + raise ValueError("smooth only accepts 1 dimension arrays.") if x.size < window_len: - raise ValueError, "Input vector needs to be bigger than window size." + raise ValueError("Input vector needs to be bigger than window size.") if window_len < 3: return x if not window in ['flat', 'hanning', 'hamming', 'bartlett', 'blackman']: - raise ValueError, "Window is on of 'flat', 'hanning', 'hamming', 'bartlett', 'blackman'" + raise ValueError("Window is on of 'flat', 'hanning', 'hamming', 'bartlett', 'blackman'") s = numpy.r_[2 * x[0] - x[window_len:1:-1], x, 2 * x[-1] - x[-1:-window_len:-1]] diff --git a/timeside/tools/cache.py b/timeside/tools/cache.py index 6681e1c..592524a 100644 --- a/timeside/tools/cache.py +++ b/timeside/tools/cache.py @@ -66,7 +66,7 @@ class Cache(object): def read_bin(self, file): path = self.dir + os.sep + file - f = open(path, 'r') + f = open(path, 'r') data = f.read() f.close() return data @@ -74,7 +74,7 @@ class Cache(object): def read_stream_bin(self, file): path = self.dir + os.sep + file chunk_size = 0x1000 - f = open(path, 'r') + f = open(path, 'r') while True: _chunk = f.read(chunk_size) if not len(_chunk): -- 2.39.5