pylint: fix warnings (mostly import-related)

This commit is contained in:
Roman Zeyde
2018-02-18 10:57:21 +02:00
parent 93a174142b
commit 0e29f9a606
15 changed files with 68 additions and 51 deletions

View File

@@ -1,14 +1,18 @@
#!/usr/bin/env python
# PYTHON_ARGCOMPLETE_OK
from . import main, calib, audio, async
from .config import bitrates
from . import version
import argparse
import logging
import os
import sys
import zlib
import logging
import argparse
from . import async
from . import audio
from . import calib
from . import main
from . import version
from .config import bitrates
# Python 3 has `buffer` attribute for byte-based I/O
_stdin = getattr(sys.stdin, 'buffer', sys.stdin)
@@ -97,6 +101,7 @@ def get_volume_cmd(args):
for c in volume_controllers:
if os.system(c['test']) == 0:
return c[args.command]
return None
def wrap(cls, stream, enable):

View File

@@ -1,8 +1,9 @@
"""Asynchronous Reading capabilities for amodem."""
import threading
import six # since `Queue` module was renamed to `queue` (in Python 3)
import logging
import threading
import six # since `Queue` module was renamed to `queue` (in Python 3)
log = logging.getLogger()

View File

@@ -1,15 +1,16 @@
"""Calibration capabilities for amodem."""
import itertools
import logging
import subprocess
import numpy as np
from . import common
from . import dsp
from . import sampling
from . import stream
import numpy as np
import itertools
import logging
import subprocess
log = logging.getLogger(__name__)
@@ -104,6 +105,7 @@ def volume_calibration(result_iterator, volume_ctl):
def iter_window(iterable, size):
# pylint: disable=stop-iteration-return
block = []
while True:
item = next(iterable)

View File

@@ -4,9 +4,10 @@ Commom utilities and procedures for amodem.
"""
import itertools
import logging
import numpy as np
import logging
log = logging.getLogger(__name__)
scaling = 32000.0 # out of 2**15
@@ -74,6 +75,7 @@ def take(iterable, n):
def izip(iterables):
""" "Python 3" zip re-implementation for Python 2. """
# pylint: disable=stop-iteration-return
iterables = [iter(iterable) for iterable in iterables]
while True:
yield tuple([next(iterable) for iterable in iterables])

View File

@@ -1,14 +1,15 @@
"""Signal detection capabilities for amodem."""
import collections
import itertools
import logging
import numpy as np
from . import dsp
from . import equalizer
from . import common
import numpy as np
import logging
import itertools
import collections
log = logging.getLogger(__name__)

View File

@@ -55,10 +55,9 @@ def coherence(x, omega):
n = len(x)
Hc = exp_iwt(-omega, n) / np.sqrt(0.5*n)
norm_x = norm(x)
if norm_x:
return np.dot(Hc, x) / norm_x
else:
if not norm_x:
return 0.0
return np.dot(Hc, x) / norm_x
def linear_regression(x, y):

View File

@@ -1,12 +1,13 @@
"""Audio equalizing capabilities for amodem."""
import itertools
import numpy as np
from . import dsp
from . import sampling
from . import levinson
import numpy as np
import itertools
class Equalizer(object):

View File

@@ -1,10 +1,11 @@
from . import common
import binascii
import functools
import itertools
import binascii
import struct
import logging
import struct
from . import common
log = logging.getLogger(__name__)

View File

@@ -1,6 +1,8 @@
import numpy as np
import logging
import itertools
import logging
import numpy as np
from . import send as _send
from . import recv as _recv
from . import framing, common, stream, detect, sampling

View File

@@ -1,14 +1,15 @@
import functools
import itertools
import logging
import time
import numpy as np
from . import dsp
from . import common
from . import framing
from . import equalizer
import numpy as np
import logging
import itertools
import functools
import time
log = logging.getLogger(__name__)
@@ -49,10 +50,10 @@ class Receiver(object):
log.debug('Prefix OK')
def _train(self, sampler, order, lookahead):
Nfreq = len(self.frequencies)
equalizer_length = equalizer.equalizer_length
train_symbols = self.equalizer.train_symbols(equalizer_length)
train_signal = self.equalizer.modulator(train_symbols) * Nfreq
train_signal = (self.equalizer.modulator(train_symbols) *
len(self.frequencies))
prefix = postfix = equalizer.silence_length * self.Nsym
signal_length = equalizer_length * self.Nsym + prefix + postfix
@@ -138,7 +139,7 @@ class Receiver(object):
def _update_sampler(self, errors, sampler):
err = np.array([e for v in errors.values() for e in v])
err = np.mean(np.angle(err))/(2*np.pi) if len(err) else 0
err = np.mean(np.angle(err))/(2*np.pi) if err.size else 0
errors.clear()
sampler.freq -= self.freq_err_gain * err

View File

@@ -1,8 +1,8 @@
#!/usr/bin/env python
import numpy as np
import itertools
from amodem import common
import numpy as np
from . import common
class Interpolator(object):

View File

@@ -1,11 +1,12 @@
import itertools
import logging
import numpy as np
from . import common
from . import equalizer
from . import dsp
import numpy as np
import logging
import itertools
log = logging.getLogger(__name__)

View File

@@ -8,6 +8,7 @@ import pytest
def concat(iterable):
return bytearray(itertools.chain.from_iterable(iterable))
r = random.Random(0)
blob = bytearray(r.randrange(0, 256) for i in range(64 * 1024))

View File

@@ -20,6 +20,6 @@ def test_resample():
def test_coeffs():
I = sampling.Interpolator(width=4, resolution=16)
err = I.filt[0] - [0, 0, 0, 1, 0, 0, 0, 0]
interp = sampling.Interpolator(width=4, resolution=16)
err = interp.filt[0] - [0, 0, 0, 1, 0, 0, 0, 0]
assert np.max(np.abs(err)) < 1e-10

View File

@@ -1,5 +1,5 @@
[tox]
envlist = py27,py34
envlist = py27,py3
[testenv]
deps=
pytest
@@ -10,6 +10,6 @@ deps=
six
commands=
pep8 amodem/ scripts/
pylint --extension-pkg-whitelist=numpy --report=no amodem --rcfile .pylintrc
pylint --extension-pkg-whitelist=numpy --reports=no amodem --rcfile .pylintrc
coverage run --source amodem/ --omit="*/__main__.py" -m py.test -v
coverage report