Skip to content

Commit

Permalink
Add amodem.tests to source distribution
Browse files Browse the repository at this point in the history
Also, fix a few pylint issues.
  • Loading branch information
romanz committed Oct 24, 2024
1 parent a8e8bbb commit 1d5fb11
Show file tree
Hide file tree
Showing 16 changed files with 51 additions and 56 deletions.
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[MESSAGES CONTROL]
disable=invalid-name, missing-docstring, too-many-instance-attributes, too-few-public-methods, logging-format-interpolation, consider-using-with
disable=invalid-name, missing-docstring, too-many-instance-attributes, too-few-public-methods, logging-format-interpolation, consider-using-with, redefined-outer-name
Empty file added amodem/tests/__init__.py
Empty file.
4 changes: 2 additions & 2 deletions amodem/tests/test_alsa.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from amodem import alsa, config

import mock

from .. import alsa, config


def test_alsa():
interface = alsa.Interface(config=config.fastest())
Expand Down
9 changes: 6 additions & 3 deletions amodem/tests/test_async_reader.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import mock
import logging
import time

import mock
import pytest
from amodem import async_reader
import logging

from .. import async_reader


logging.basicConfig(format='%(message)s')

Expand Down
6 changes: 3 additions & 3 deletions amodem/tests/test_audio.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from amodem import audio, config

import mock
import pytest

from .. import audio, config


def test():
length = 1024
Expand Down Expand Up @@ -31,4 +31,4 @@ def test():
s.close()

with pytest.raises(Exception):
interface._error_check(1)
interface._error_check(1) # pylint: disable=protected-access
11 changes: 5 additions & 6 deletions amodem/tests/test_calib.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
from amodem import calib
from amodem import common
from amodem import config

from io import BytesIO
import random

import mock
import numpy as np
import random
import pytest
import mock

from .. import calib, common, config


config = config.fastest()

Expand Down
4 changes: 2 additions & 2 deletions amodem/tests/test_common.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from amodem import common
from amodem import config
import numpy as np

from .. import common, config


def iterlist(x, *args, **kwargs):
x = np.array(x)
Expand Down
2 changes: 1 addition & 1 deletion amodem/tests/test_configs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from amodem import config
from .. import config


def test_bitrates():
Expand Down
15 changes: 5 additions & 10 deletions amodem/tests/test_detect.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import numpy as np
import pytest

from amodem import dsp
from amodem import recv
from amodem import detect
from amodem import equalizer
from amodem import sampling
from amodem import config
from amodem import common
from .. import common, config, detect, dsp, equalizer, recv, sampling

config = config.fastest()


Expand All @@ -17,7 +12,7 @@ def test_detect():
x = np.cos(2 * np.pi * config.Fc * t)

detector = detect.Detector(config, pylab=common.Dummy())
samples, amp, freq_err = detector.run(x)
_samples, amp, freq_err = detector.run(x)
assert abs(1 - amp) < 1e-12
assert abs(freq_err) < 1e-12

Expand All @@ -39,11 +34,11 @@ def symbols_stream(signal):
sampler = sampling.Sampler(signal)
return dsp.Demux(sampler=sampler, omegas=[omega], Nsym=config.Nsym)
r = recv.Receiver(config, pylab=common.Dummy())
r._prefix(symbols_stream(signal))
r._prefix(symbols_stream(signal)) # pylint: disable=protected-access

with pytest.raises(ValueError):
silence = 0 * signal
r._prefix(symbols_stream(silence))
r._prefix(symbols_stream(silence)) # pylint: disable=protected-access


def test_find_start():
Expand Down
13 changes: 6 additions & 7 deletions amodem/tests/test_dsp.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from amodem import dsp
from amodem import sampling
from amodem import config
import utils

import numpy as np
import random
import itertools

import numpy as np

from .. import dsp, sampling, config
from . import utils

config = config.fastest()


Expand Down Expand Up @@ -69,7 +68,7 @@ def quantize(q, s):
def test_overflow():
q = dsp.MODEM(config.symbols)
r = np.random.RandomState(seed=0)
for i in range(10000):
for _ in range(10000):
s = 10*(r.normal() + 1j * r.normal())
quantize(q, s)

Expand Down
7 changes: 3 additions & 4 deletions amodem/tests/test_equalizer.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from numpy.random import RandomState
import numpy as np

import utils
from amodem import equalizer
from amodem import dsp
from amodem import config
from . import utils
from .. import config, dsp, equalizer

config = config.fastest()


Expand Down
5 changes: 3 additions & 2 deletions amodem/tests/test_framing.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from amodem import framing
import random
import itertools
import random

import pytest

from .. import framing


def concat(iterable):
return bytearray(itertools.chain.from_iterable(iterable))
Expand Down
6 changes: 3 additions & 3 deletions amodem/tests/test_sampling.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from amodem import sampling
from amodem import common
from io import BytesIO

import numpy as np
from io import BytesIO

from .. import common, sampling


def test_resample():
Expand Down
3 changes: 2 additions & 1 deletion amodem/tests/test_stream.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from amodem import stream
import subprocess as sp
import sys

from .. import stream

script = br"""
import sys
import time
Expand Down
16 changes: 7 additions & 9 deletions amodem/tests/test_transfer.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
from amodem import main
from amodem import common
from amodem import sampling
from amodem import config
import utils

import numpy as np
import os
from io import BytesIO
import logging
import os

import numpy as np
import pytest
import logging

from .. import common, config, main, sampling
from . import utils

logging.basicConfig(level=logging.DEBUG, # useful for debugging
format='%(asctime)s %(levelname)-12s %(message)s')

Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python
from setuptools import setup
from setuptools import setup, find_packages
from setuptools.command.test import test as TestCommand

class PyTest(TestCommand):
Expand All @@ -21,7 +21,7 @@ def run_tests(self):
author_email='[email protected]',
license='MIT',
url='http://github.com/romanz/amodem',
packages=['amodem'],
packages=find_packages(),
tests_require=['pytest'],
cmdclass={'test': PyTest},
install_requires=['numpy'],
Expand Down

0 comments on commit 1d5fb11

Please sign in to comment.