Skip to content

Commit 9155d8e

Browse files
committed
no pylint errors anymore
1 parent dd175ac commit 9155d8e

File tree

6 files changed

+62
-53
lines changed

6 files changed

+62
-53
lines changed

fourier/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from .fourier import *
1+
# from .fourier import *

fourier/fourier.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def fft_vectorized(input_data):
4444
factor = np.exp(-1j * np.pi * np.arange(dot_product.shape[0])
4545
/ dot_product.shape[0])[:, None]
4646
dot_product = np.vstack([data_even + factor * data_odd,
47-
data_even - factor * data_odd])
47+
data_even - factor * data_odd])
4848

4949
return dot_product.ravel()
5050

plot/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
"""
22
Initialize plot.py and make it importable
33
"""
4-
from .plot import *
4+
from .plot import psd

plot/plot.py

Lines changed: 48 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
import numpy as np
55
from fourier import fourier
66

7+
# pylint: disable-msg=R0913
8+
# pylint: disable-msg=R0914
9+
# pylint: disable-msg=R0912
10+
11+
712
def window_hanning(window):
813
'''
914
Return window times the hanning window of len(window).
@@ -180,9 +185,9 @@ def stride_windows(samples, sample_size, noverlap=None, axis=0):
180185
noverlap = 0
181186

182187
if noverlap >= sample_size:
183-
raise ValueError('noverlap must be less than n')
188+
raise ValueError('noverlap must be less than sample_size')
184189
if sample_size < 1:
185-
raise ValueError('n cannot be less than 1')
190+
raise ValueError('sample_size cannot be less than 1')
186191

187192
samples = np.asarray(samples)
188193

@@ -245,7 +250,7 @@ def detrend_mean(sequence, axis=None):
245250
return sequence - sequence.mean(axis, keepdims=True)
246251

247252

248-
def detrend_none(samples, axis=None): # pylint: disable-msg=
253+
def detrend_none(samples, axis=None): # pylint: disable-msg=W0613
249254
'''
250255
Return samples: no detrending.
251256
@@ -275,7 +280,7 @@ def detrend_none(samples, axis=None): # pylint: disable-msg=
275280
'''
276281
return samples
277282

278-
283+
# pylint: disable-msg=C0103
279284
def detrend_linear(y):
280285
'''
281286
Return x minus best fit line; 'linear' detrending.
@@ -322,18 +327,20 @@ def detrend_linear(y):
322327
a = y.mean() - b*x.mean()
323328
return y - (b*x + a)
324329

325-
def apply_window(x, window, axis=0, return_window=None):
330+
# pylint: enable-msg=C0103
331+
332+
def apply_window(samples, window, axis=0, return_window=None):
326333
'''
327334
Apply the given window to the given 1D or 2D array along the given axis.
328335
329336
Parameters
330337
----------
331-
x : 1D or 2D array or sequence
338+
samples : 1D or 2D array or sequence
332339
Array or sequence containing the data.
333340
334341
window : function or array.
335342
Either a function to generate a window or an array with length
336-
*x*.shape[*axis*]
343+
*samples*.shape[*axis*]
337344
338345
axis : integer
339346
The axis over which to do the repetition.
@@ -342,46 +349,46 @@ def apply_window(x, window, axis=0, return_window=None):
342349
return_window : bool
343350
If true, also return the 1D values of the window that was applied
344351
'''
345-
x = np.asarray(x)
352+
samples = np.asarray(samples)
346353

347-
if x.ndim < 1 or x.ndim > 2:
354+
if samples.ndim < 1 or samples.ndim > 2:
348355
raise ValueError('only 1D or 2D arrays can be used')
349-
if axis+1 > x.ndim:
356+
if axis+1 > samples.ndim:
350357
raise ValueError('axis(=%s) out of bounds' % axis)
351358

352-
xshape = list(x.shape)
359+
xshape = list(samples.shape)
353360
xshapetarg = xshape.pop(axis)
354361

355362
# if cbook.iterable(window):
356363
# print("CBOOK MANE")
357364
# if len(window) != xshapetarg:
358365
# raise ValueError('The len(window) must be the same as the shape '
359-
# 'of x for the chosen axis')
366+
# 'of samples for the chosen axis')
360367
# window_vals = window
361368
# else:
362-
window_vals = window(np.ones(xshapetarg, dtype=x.dtype))
369+
window_vals = window(np.ones(xshapetarg, dtype=samples.dtype))
363370

364-
if x.ndim == 1:
365-
if return_window:
366-
return window_vals * x, window_vals
371+
if samples.ndim == 1:
372+
if return_window: # pylint: disable-msg=R1705
373+
return window_vals * samples, window_vals
367374
else:
368-
return window_vals * x
375+
return window_vals * samples
369376

370377
xshapeother = xshape.pop()
371378

372379
otheraxis = (axis+1) % 2
373380

374-
window_valsRep = stride_repeat(window_vals, xshapeother, axis=otheraxis)
381+
window_vals_rep = stride_repeat(window_vals, xshapeother, axis=otheraxis)
375382

376-
if return_window:
377-
return window_valsRep * x, window_vals
383+
if return_window: # pylint: disable-msg=R1705
384+
return window_vals_rep * samples, window_vals
378385
else:
379-
return window_valsRep * x
386+
return window_vals_rep * samples
380387

381-
def stride_repeat(x, n, axis=0):
388+
def stride_repeat(samples, sample_size, axis=0):
382389
'''
383-
Repeat the values in an array in a memory-efficient manner. Array x is
384-
stacked vertically n times.
390+
Repeat the values in an array in a memory-efficient manner. Array samples is
391+
stacked vertically sample_size times.
385392
386393
.. warning::
387394
@@ -391,10 +398,10 @@ def stride_repeat(x, n, axis=0):
391398
392399
Parameters
393400
----------
394-
x : 1D array or sequence
401+
samples : 1D array or sequence
395402
Array or sequence containing the data.
396403
397-
n : integer
404+
sample_size : integer
398405
The number of time to repeat the array.
399406
400407
axis : integer
@@ -407,27 +414,27 @@ def stride_repeat(x, n, axis=0):
407414
'''
408415
if axis not in [0, 1]:
409416
raise ValueError('axis must be 0 or 1')
410-
x = np.asarray(x)
411-
if x.ndim != 1:
417+
samples = np.asarray(samples)
418+
if samples.ndim != 1:
412419
raise ValueError('only 1-dimensional arrays can be used')
413420

414-
if n == 1:
415-
if axis == 0:
416-
return np.atleast_2d(x)
421+
if sample_size == 1:
422+
if axis == 0: # pylint: disable-msg=R1705
423+
return np.atleast_2d(samples)
417424
else:
418-
return np.atleast_2d(x).T
419-
if n < 1:
420-
raise ValueError('n cannot be less than 1')
425+
return np.atleast_2d(samples).T
426+
if sample_size < 1:
427+
raise ValueError('sample_size cannot be less than 1')
421428

422429
# np.lib.stride_tricks.as_strided easily leads to memory corruption for
423-
# non integer shape and strides, i.e. n. See #3845.
424-
n = int(n)
430+
# non integer shape and strides, i.e. sample_size. See #3845.
431+
sample_size = int(sample_size)
425432

426433
if axis == 0:
427-
shape = (n, x.size)
428-
strides = (0, x.strides[0])
434+
shape = (sample_size, samples.size)
435+
strides = (0, samples.strides[0])
429436
else:
430-
shape = (x.size, n)
431-
strides = (x.strides[0], 0)
437+
shape = (samples.size, sample_size)
438+
strides = (samples.strides[0], 0)
432439

433-
return np.lib.stride_tricks.as_strided(x, shape=shape, strides=strides)
440+
return np.lib.stride_tricks.as_strided(samples, shape=shape, strides=strides)

tests/context.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
"""
22
Context import file. This is used by the test files.
33
"""
4+
# pylint: disable-msg=C0414
5+
# pylint: disable-msg=W0611
6+
# pylint: disable-msg=C0412
7+
# pylint: disable-msg=C0413
48
import sys
59
import os
610
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
7-
# pylint: disable-msg=C0413
811
import fourier
912
import filterbank.header as header
1013
import plot

tests/test_plot.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
"""
22
plot.py unit tests
33
"""
4+
# import unittest
5+
# import numpy as np
46

5-
import unittest
6-
import numpy as np
7+
# from context import plot # pylint: disable-msg=E0611
78

8-
from context import plot # pylint: disable-msg=E0611
9-
10-
class TestPlot(unittest.TestCase):
11-
"""
12-
Testclass for testing the plot class
13-
"""
9+
# class TestPlot(unittest.TestCase):
10+
# """
11+
# Testclass for testing the plot class
12+
# """

0 commit comments

Comments
 (0)