Skip to content

Commit f000da5

Browse files
committed
linting is error free
1 parent 6e3dde5 commit f000da5

File tree

9 files changed

+34
-10
lines changed

9 files changed

+34
-10
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ addopts = [
1717
]
1818

1919
[tool.ruff]
20-
include = ["ssp/**"]
20+
include = ["ssp/**", "tests/**"]
2121

2222
line-length = 100
2323
indent-width = 4

tests/test_adaptive.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Test the adaptive module."""

tests/test_lattice.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Test functions for the lattice module."""

tests/test_levinson.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
import logging
44

55
import numpy as np
6-
from ssp import levinson
76

7+
from ssp import levinson
88

99
logger = logging.getLogger(__name__)
1010

1111

1212
def test_glev():
13-
'''Example 5.3.1, Page 266'''
13+
"""Example 5.3.1, Page 266."""
1414
r = [4, 2, 1]
1515
b = [9, 6, 12]
1616

@@ -23,7 +23,7 @@ def test_glev():
2323

2424

2525
def test_gtor() -> None:
26-
'''Based on example 5.2.6'''
26+
"""Based on example 5.2.6."""
2727
expected_rx = np.array([2, -1, -1/4, 1/8])
2828

2929
gamma = [1/2, 1/2, 1/2]
@@ -33,7 +33,7 @@ def test_gtor() -> None:
3333

3434

3535
def test_atog() -> None:
36-
36+
"""The m-file for the step-down recursion."""
3737
a = [1, 0.5, -0.1, -0.5]
3838
expected_g = np.array([0.5, 0.2, -0.5])
3939

@@ -45,6 +45,11 @@ def test_atog() -> None:
4545

4646

4747
def test_rtog() -> None:
48+
"""Companion m-file.
49+
50+
Performs mapping from a sequence of
51+
autocorrelations r to the reflection coefficient g.
52+
"""
4853
rx = [2, -1, -1/4, 1/8]
4954
expected_g = np.array([0.5, 0.5, 0.5])
5055

@@ -56,6 +61,7 @@ def test_rtog() -> None:
5661

5762

5863
def test_ator() -> None:
64+
"""Finds the autocorrelation sequence from a set of filter coefficients."""
5965
a = [1, 1, 7/8, 1/2]
6066
epsilon = 2 * (3 / 4)**3
6167
b = epsilon**2
@@ -69,6 +75,7 @@ def test_ator() -> None:
6975

7076

7177
def test_gtoa() -> None:
78+
"""The step-up recursion."""
7279
gamma = [0.5, 0.2, -0.5]
7380
expected_a = np.array([1, 0.5, -0.1, -0.5])
7481

@@ -79,6 +86,7 @@ def test_gtoa() -> None:
7986
assert np.allclose(a, expected_a)
8087

8188
def test_rtoa() -> None:
89+
"""m-file for the Levinson-Durbin recursion."""
8290
rx = np.array([2, -1, -1/4, 1/8])
8391
expected_a = [1, 1, 7/8, 1/2]
8492
expected_eps = 2 * (3 / 4)**3

tests/test_modeling.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
import logging
44

55
import numpy as np
6-
import scipy.signal as signal
7-
from ssp import modeling, system
6+
from scipy import signal
87

8+
from ssp import modeling, system
99

1010
logger = logging.getLogger(__name__)
1111

1212

1313
def test_pade() -> None:
14+
"""Pade Approximation."""
1415
x = [1, 1.5, 0.75, 0.1875, 0.0938]
1516
expected_a = [1, -1.5, 1.5]
1617
expected_b = [1]
@@ -39,6 +40,7 @@ def test_pade() -> None:
3940

4041

4142
def test_prony():
43+
"""Prony method."""
4244
N = 21
4345
T = 2 * (N - 1) + 1
4446
xn = np.ones(T)
@@ -49,6 +51,7 @@ def test_prony():
4951

5052

5153
def test_shanks():
54+
"""Shank's method."""
5255
N = 21
5356
T = 10 * (N - 1) + 1
5457
xn = np.ones(T)
@@ -66,6 +69,7 @@ def test_shanks():
6669

6770

6871
def test_spike():
72+
"""m-file to find the least squares inverse filter."""
6973
gn = np.array([-0.2, 0, 1])
7074
h, err = modeling.spike(gn, 4, 11)
7175
d = np.convolve(h, gn)
@@ -74,10 +78,12 @@ def test_spike():
7478
logger.info(f"{d=}, {np.argmax(d)=}")
7579

7680

77-
def test_ipf(): ...
81+
def test_ipf():
82+
"""Iterative prefiltering."""
7883

7984

8085
def test_acm():
86+
"""m-file for the autocorrelation method."""
8187
x = np.ones(20)
8288
x[1::2] = x[1::2] * -1
8389
logger.info(x)
@@ -88,6 +94,7 @@ def test_acm():
8894

8995

9096
def test_covm():
97+
"""Covariance method."""
9198
x = np.ones(20)
9299
x[1::2] = x[1::2] * -1
93100
logger.info(x)
@@ -98,7 +105,8 @@ def test_covm():
98105

99106

100107
def test_durbin():
101-
N = 64
108+
"""Durbin's method."""
109+
#N = 64
102110
ap = [1, 0.7348, 1.882, 0.7057, 0.8851]
103111

104112
zeros, poles, _ = signal.tf2zpk([1], ap)

tests/test_optimal.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
""""""
1+
"""Test optimal."""
22

33
import numpy as np
4+
45
from ssp import optimal
56

67

78
def test_kalman():
9+
"""Discrete Kalman filter."""
810
av = 1
911
aw = 0.36
1012
A = 0.8

tests/test_spectrum.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Spectrum."""

tests/test_state.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88

99
def test_convm():
10+
"""Set up a convoluston matrix."""
1011
x = np.array([1, 2, 3])
1112
p = 4
1213

@@ -20,6 +21,7 @@ def test_convm():
2021

2122

2223
def test_covar():
24+
"""Form a covariance matrix."""
2325
x = np.array([1, 2, 3])
2426
p = 4
2527

tests/test_system.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Discrete-time system."""

0 commit comments

Comments
 (0)