Skip to content

Commit 87e6732

Browse files
committed
Use frozenset instead of list line 88 filters.py to improve efficiency
1 parent 6db9cdb commit 87e6732

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

rampy/filters.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def smooth(x,y,method="whittaker",**kwargs):
6565
raise ValueError("Method should be on 'GCVSmoothedNSpline','MSESmoothedNSpline','DOFSmoothedNSpline','whittaker','savgol','flat', 'hanning', 'hamming', 'bartlett', 'blackman'")
6666

6767
if (method == "GCVSmoothedNSpline") or (method == "MSESmoothedNSpline") or (method == "DOFSmoothedNSpline"): # gcvspline methods
68-
68+
6969
try: # we test if gcvspline is installed
7070
import gcvspline
7171
except ImportError:
@@ -85,7 +85,7 @@ def smooth(x,y,method="whittaker",**kwargs):
8585
return whittaker(y,Lambda=lam,d=d)
8686
elif method == "savgol": # Savtisky-Golay filter
8787
return scipy.signal.savgol_filter(y, window_len, polyorder)
88-
elif method in ['flat', 'hanning', 'hamming', 'bartlett', 'blackman']: # various window filters, from https://scipy-cookbook.readthedocs.io/items/SignalSmooth.html?highlight=smooth
88+
elif method in frozenset(('flat', 'hanning', 'hamming', 'bartlett', 'blackman')): # various window filters, from https://scipy-cookbook.readthedocs.io/items/SignalSmooth.html?highlight=smooth
8989

9090
s=np.r_[y[window_len-1:0:-1],y,y[-2:-window_len-1:-1]]
9191
if method == 'flat': #moving average
@@ -171,7 +171,7 @@ def spectrafilter(spectre,filtertype,fq,numtaps,columns):
171171
b, a = signal.butter(numtaps, [(cutf/nyq_rate)], btype = filtertype)
172172
else:
173173
b, a = signal.butter(numtaps, [(cutf[0]/nyq_rate),(cutf[1]/nyq_rate)], btype = filtertype)
174-
174+
175175
out[:,columns[i]] = signal.filtfilt(b, a, y) # filter with phase shift correction
176-
176+
177177
return out

0 commit comments

Comments
 (0)