Skip to content

Commit d1adb7f

Browse files
authored
Enforce flake8 E841 and E821 (#504)
1 parent 7ef1178 commit d1adb7f

File tree

6 files changed

+7
-26
lines changed

6 files changed

+7
-26
lines changed

.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[flake8]
22
max-line-length = 120
3-
ignore = E305,E402,E721,E741,F401,F403,F405,F821,F841,F999,W503,W504
3+
ignore = E305,E402,E721,E741,F401,F403,F405,F999,W503,W504
44
exclude = build,docs/source,_ext

test/test_batch_consistency.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def _test_batch(functional, tensor, *args, **kwargs):
6464
expected = expected.repeat(*ind)
6565

6666
torch.random.manual_seed(42)
67-
computed = functional(tensors.clone(), *args, **kwargs)
67+
_ = functional(tensors.clone(), *args, **kwargs)
6868

6969

7070
class TestFunctional(unittest.TestCase):

test/test_functional_filtering.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import os
2-
import time
32
import unittest
43

54
import torch
@@ -450,17 +449,13 @@ def test_perf_biquad_filtering(self):
450449
# SoX method
451450
E = torchaudio.sox_effects.SoxEffectsChain()
452451
E.set_input_file(fn_sine)
453-
_timing_sox = time.time()
454452
E.append_effect_to_chain("biquad", [b0, b1, b2, a0, a1, a2])
455-
waveform_sox_out, sr = E.sox_build_flow_effects()
456-
_timing_sox_run_time = time.time() - _timing_sox
453+
waveform_sox_out, _ = E.sox_build_flow_effects()
457454

458-
_timing_lfilter_filtering = time.time()
459-
waveform, sample_rate = torchaudio.load(fn_sine, normalization=True)
455+
waveform, _ = torchaudio.load(fn_sine, normalization=True)
460456
waveform_lfilter_out = F.lfilter(
461457
waveform, torch.tensor([a0, a1, a2]), torch.tensor([b0, b1, b2])
462458
)
463-
_timing_lfilter_run_time = time.time() - _timing_lfilter_filtering
464459

465460
assert torch.allclose(waveform_sox_out, waveform_lfilter_out, atol=1e-4)
466461
_test_torchscript_functional(

test/test_sox_effects.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ def test_vol(self):
257257
vol = torchaudio.transforms.Vol(gain, gain_type)
258258
z = vol(x_orig)
259259
# check if effect worked
260-
self.assertTrue(x.allclose(vol(x_orig), rtol=1e-4, atol=1e-4))
260+
self.assertTrue(x.allclose(z, rtol=1e-4, atol=1e-4))
261261

262262

263263
if __name__ == '__main__':

test/test_transforms.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,8 @@ def test_compute_deltas_transform_same_as_functional(self, atol=1e-6, rtol=1e-8)
212212

213213
def test_compute_deltas_twochannel(self):
214214
specgram = torch.tensor([1., 2., 3., 4.]).repeat(1, 2, 1)
215-
expected = torch.tensor([[[0.5, 1.0, 1.0, 0.5],
216-
[0.5, 1.0, 1.0, 0.5]]])
215+
_ = torch.tensor([[[0.5, 1.0, 1.0, 0.5],
216+
[0.5, 1.0, 1.0, 0.5]]])
217217
transform = transforms.ComputeDeltas()
218218
computed = transform(specgram)
219219
self.assertTrue(computed.shape == specgram.shape, (computed.shape, specgram.shape))

torchaudio/functional.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -463,8 +463,6 @@ def create_fb_matrix(
463463
# freq bins
464464
# Equivalent filterbank construction by Librosa
465465
all_freqs = torch.linspace(0, sample_rate // 2, n_freqs)
466-
i_freqs = all_freqs.ge(f_min) & all_freqs.le(f_max)
467-
freqs = all_freqs[i_freqs]
468466

469467
# calculate mel freq bins
470468
# hertz to mel(f) is 2595. * math.log10(1. + (f / 700.))
@@ -710,9 +708,6 @@ def lfilter(
710708
Returns:
711709
Tensor: Waveform with dimension of `(..., time)`. Output will be clipped to -1 to 1.
712710
"""
713-
714-
dim = waveform.dim()
715-
716711
# pack batch
717712
shape = waveform.size()
718713
waveform = waveform.view(-1, shape[-1])
@@ -820,12 +815,8 @@ def highpass_biquad(
820815
Returns:
821816
Tensor: Waveform dimension of `(..., time)`
822817
"""
823-
824-
GAIN = 1.
825818
w0 = 2 * math.pi * cutoff_freq / sample_rate
826-
A = math.exp(GAIN / 40.0 * math.log(10))
827819
alpha = math.sin(w0) / 2. / Q
828-
mult = _dB2Linear(max(GAIN, 0))
829820

830821
b0 = (1 + math.cos(w0)) / 2
831822
b1 = -1 - math.cos(w0)
@@ -853,12 +844,8 @@ def lowpass_biquad(
853844
Returns:
854845
Tensor: Waveform of dimension of `(..., time)`
855846
"""
856-
857-
GAIN = 1.
858847
w0 = 2 * math.pi * cutoff_freq / sample_rate
859-
A = math.exp(GAIN / 40.0 * math.log(10))
860848
alpha = math.sin(w0) / 2 / Q
861-
mult = _dB2Linear(max(GAIN, 0))
862849

863850
b0 = (1 - math.cos(w0)) / 2
864851
b1 = 1 - math.cos(w0)
@@ -1030,7 +1017,6 @@ def band_biquad(
10301017
https://www.w3.org/2011/audio/audio-eq-cookbook.html#APF
10311018
"""
10321019
w0 = 2 * math.pi * central_freq / sample_rate
1033-
alpha = math.sin(w0) / 2 / Q
10341020
bw_Hz = central_freq / Q
10351021

10361022
a0 = 1.

0 commit comments

Comments
 (0)