From b57dc14b72eef038e6c560f2724617a2540500e2 Mon Sep 17 00:00:00 2001
From: Abram Claycomb <aclaycomb@usgs.gov>
Date: Tue, 13 Nov 2018 16:52:40 -0700
Subject: [PATCH] fix linting more

---
 geomagio/algorithm/FilterAlgorithm.py       | 22 ++++++++++-----------
 test/algorithm_test/FilterAlgorithm_test.py |  7 +++----
 2 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/geomagio/algorithm/FilterAlgorithm.py b/geomagio/algorithm/FilterAlgorithm.py
index e73c0cdb8..3ddddf6d0 100644
--- a/geomagio/algorithm/FilterAlgorithm.py
+++ b/geomagio/algorithm/FilterAlgorithm.py
@@ -1,12 +1,10 @@
 from __future__ import absolute_import
 
 from .Algorithm import Algorithm
-import json
 import numpy as np
 from numpy.lib import stride_tricks as npls
 import scipy.signal as sps
 from obspy.core import Stream, Stats
-import sys
 
 
 class FilterAlgorithm(Algorithm):
@@ -19,12 +17,12 @@ class FilterAlgorithm(Algorithm):
                  data_type=None):
         Algorithm.__init__(self, inchannels=inchannels,
             outchannels=outchannels)
-        self.numtaps=91
+        self.numtaps = 91
         # get filter window (standard intermagnet one-minute filter)
         self.window = sps.get_window(window=('gaussian', 15.8734),
                                              Nx=self.numtaps)
         # normalize filter window
-        self.window = self.window/np.sum(self.window)
+        self.window = self.window / np.sum(self.window)
         self.decimation = 60
         self.sample_period = 1.0
         self.data_type = data_type
@@ -94,9 +92,9 @@ class FilterAlgorithm(Algorithm):
 
             filtered = self.firfilter(data, self.window, step)
 
-            stats=Stats(trace.stats)
-            #stats.channel = trace_chan_dict2[stats.channel]
-            stats.delta = stats.delta*step
+            stats = Stats(trace.stats)
+            # stats.channel = trace_chan_dict2[stats.channel]
+            stats.delta = stats.delta * step
             if 'processing' in stats:
                 stats.pop('processing')
             stats.npts = filtered.shape[0]
@@ -108,7 +106,7 @@ class FilterAlgorithm(Algorithm):
         return out
 
     @staticmethod
-    def firfilter(data, window, step, allowed_bad = 0.1):
+    def firfilter(data, window, step, allowed_bad=0.1):
         """Run fir filter for a numpy array.
         Processes all traces in the stream.
         Parameters
@@ -141,7 +139,7 @@ class FilterAlgorithm(Algorithm):
         as_masked = np.ma.masked_invalid(as_s[::step], copy=True)
         # sums of the total 'weights' of the filter corresponding to
         # valid samples
-        as_weight_sums =  np.dot(window, (~as_masked.mask).T)
+        as_weight_sums = np.dot(window, (~as_masked.mask).T)
         # mark the output locations as 'bad' that have missing input weights
         # that sum to greater than the allowed_bad threshhold
         as_invalid_masked = np.ma.masked_less(as_weight_sums, 1 - allowed_bad)
@@ -183,9 +181,9 @@ class FilterAlgorithm(Algorithm):
             end of input required to generate requested output.
         """
 
-        half = self.numtaps//2
-        start = start - half*self.sample_period
-        end = end + half*self.sample_period
+        half = self.numtaps // 2
+        start = start - half * self.sample_period
+        end = end + half * self.sample_period
 
         return (start, end)
 
diff --git a/test/algorithm_test/FilterAlgorithm_test.py b/test/algorithm_test/FilterAlgorithm_test.py
index 720654931..18806f0d2 100644
--- a/test/algorithm_test/FilterAlgorithm_test.py
+++ b/test/algorithm_test/FilterAlgorithm_test.py
@@ -2,13 +2,12 @@ from geomagio.algorithm import FilterAlgorithm as filt
 import geomagio.iaga2002 as i2
 from nose.tools import assert_almost_equals
 
+
 def test_process():
     """
     Check one minute filter data processing versus files generated from
     original script
     """
-
-
     # load boulder Jan 16 files from /etc/ directory
     min_iaga2002_file = open('etc/filter/BOU20180901vmin.min')
     min_iaga2002_string = min_iaga2002_file.read()
@@ -21,8 +20,8 @@ def test_process():
     sec = factory.parse_string(sec_iaga2002_string)
 
     # process hezf (raw) channels with loaded transform
-    a = filt(inchannels=('H','E','Z','F'),
-                         outchannels=('H','E','Z','F'))
+    a = filt(inchannels=('H', 'E', 'Z', 'F'),
+                         outchannels=('H', 'E', 'Z', 'F'))
 
     filt_bou = a.process(sec)
 
-- 
GitLab