Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linting is error free #38

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ addopts = [
]

[tool.ruff]
include = ["ssp/**"]
include = ["ssp/**", "tests/**"]

line-length = 100
indent-width = 4
Expand Down
1 change: 1 addition & 0 deletions tests/test_adaptive.py
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency, let's phrase it as "Test cases for the Adaptive module."

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Test the adaptive module."""
1 change: 1 addition & 0 deletions tests/test_lattice.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Test functions for the lattice module."""
16 changes: 12 additions & 4 deletions tests/test_levinson.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import logging

import numpy as np
from ssp import levinson

from ssp import levinson

logger = logging.getLogger(__name__)


def test_glev():
'''Example 5.3.1, Page 266'''
"""Example 5.3.1, Page 266."""
r = [4, 2, 1]
b = [9, 6, 12]

Expand All @@ -23,7 +23,7 @@ def test_glev():


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

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


def test_atog() -> None:

"""The m-file for the step-down recursion."""
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not a matlabl file (m-file), this is a functional test for the step-down recursion.

a = [1, 0.5, -0.1, -0.5]
expected_g = np.array([0.5, 0.2, -0.5])

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


def test_rtog() -> None:
"""Companion m-file.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not an m-file.


Performs mapping from a sequence of
autocorrelations r to the reflection coefficient g.
"""
rx = [2, -1, -1/4, 1/8]
expected_g = np.array([0.5, 0.5, 0.5])

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


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


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

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

def test_rtoa() -> None:
"""m-file for the Levinson-Durbin recursion."""
rx = np.array([2, -1, -1/4, 1/8])
expected_a = [1, 1, 7/8, 1/2]
expected_eps = 2 * (3 / 4)**3
Expand Down
16 changes: 12 additions & 4 deletions tests/test_modeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
import logging

import numpy as np
import scipy.signal as signal
from ssp import modeling, system
from scipy import signal

from ssp import modeling, system

logger = logging.getLogger(__name__)


def test_pade() -> None:
"""Pade Approximation."""
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functional test for the Pade Approximation.

x = [1, 1.5, 0.75, 0.1875, 0.0938]
expected_a = [1, -1.5, 1.5]
expected_b = [1]
Expand Down Expand Up @@ -39,6 +40,7 @@ def test_pade() -> None:


def test_prony():
"""Prony method."""
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functional test for the...

N = 21
T = 2 * (N - 1) + 1
xn = np.ones(T)
Expand All @@ -49,6 +51,7 @@ def test_prony():


def test_shanks():
"""Shank's method."""
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functional test for the...

N = 21
T = 10 * (N - 1) + 1
xn = np.ones(T)
Expand All @@ -66,6 +69,7 @@ def test_shanks():


def test_spike():
"""m-file to find the least squares inverse filter."""
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not an m-file.

gn = np.array([-0.2, 0, 1])
h, err = modeling.spike(gn, 4, 11)
d = np.convolve(h, gn)
Expand All @@ -74,10 +78,12 @@ def test_spike():
logger.info(f"{d=}, {np.argmax(d)=}")


def test_ipf(): ...
def test_ipf():
"""Iterative prefiltering."""
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functional test for the...



def test_acm():
"""m-file for the autocorrelation method."""
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not an m-file. Functional test for the...

x = np.ones(20)
x[1::2] = x[1::2] * -1
logger.info(x)
Expand All @@ -88,6 +94,7 @@ def test_acm():


def test_covm():
"""Covariance method."""
x = np.ones(20)
x[1::2] = x[1::2] * -1
logger.info(x)
Expand All @@ -98,7 +105,8 @@ def test_covm():


def test_durbin():
N = 64
"""Durbin's method."""
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functional test for the...

#N = 64
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just delete this line.

ap = [1, 0.7348, 1.882, 0.7057, 0.8851]

zeros, poles, _ = signal.tf2zpk([1], ap)
Expand Down
4 changes: 3 additions & 1 deletion tests/test_optimal.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
""""""
"""Test optimal."""
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test cases for the Optimal module.


import numpy as np

from ssp import optimal


def test_kalman():
"""Discrete Kalman filter."""
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functional test for the...

av = 1
aw = 0.36
A = 0.8
Expand Down
1 change: 1 addition & 0 deletions tests/test_spectrum.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Spectrum."""
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test cases for the Spectrum module.

2 changes: 2 additions & 0 deletions tests/test_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@


def test_convm():
"""Set up a convoluston matrix."""
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functional test for the...

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spelling correction: "convolution".

Functional test for the Convolution matrix.

x = np.array([1, 2, 3])
p = 4

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


def test_covar():
"""Form a covariance matrix."""
x = np.array([1, 2, 3])
p = 4

Expand Down
1 change: 1 addition & 0 deletions tests/test_system.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Discrete-time system."""
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test cases for the Discrete-Time Systems module.