Skip to content

Commit

Permalink
Add requirements in setup.py, typing, and some more tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
mmxgn committed Nov 13, 2021
1 parent 04a8eb7 commit 018419a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
8 changes: 6 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ def read(fname):

setuptools.setup(
name="yulewalker",
version="0.1",
version="0.1.1",
author="Emmanouil Theofanis Chourdakis",
author_email="eruyome@gmail.com",
author_email="emmanouil.chourdakis@nomono.co",
description="IIR Filter design using the modified Yule-Walker method",
classifiers=[
"Topic :: Scientific/Engineering",
Expand All @@ -24,4 +24,8 @@ def read(fname):
long_description=read("README.md"),
license="CeCILL-2.1",
keywords="yulewalk yulewalker iir signal-processing dsp",
install_requires=[
"numpy>=1.19.2",
"scipy>=1.5.2",
],
)
16 changes: 13 additions & 3 deletions yulewalker/yulewalker.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,15 @@ def interpolate_freq_mag(
return new_freq, new_mag


def polystab(p):
def polystab(p: np.ndarray) -> np.ndarray:
"""
Reflects the roots of polynomial `p` that are outside the unit circle back inside.
>>> polystab(np.array([[1.,2.,1.]]))
array([1., 2., 1.])
>>> polystab(np.array([[1.,2.,1.01]]))
array([1. , 1.98019802, 0.99009901])
"""
if p.ndim == 2 and (p.shape[0] == 1 or p.shape[1] == 1):
p = p.flatten()
Expand All @@ -76,7 +82,9 @@ def polystab(p):
return b


def numf(impulse_response, denominator, numerator_order):
def numf(
impulse_response: np.ndarray, denominator: np.ndarray, numerator_order: int
) -> np.ndarray:
"""
Find the numberator of the impulse response `impulse_response` of a frequency
response H = numerator/denominator.
Expand All @@ -93,7 +101,9 @@ def numf(impulse_response, denominator, numerator_order):
return b


def yulewalk(filter_order, frequencies, magnitudes, npt=512):
def yulewalk(
filter_order: int, frequencies: np.ndarray, magnitudes: np.ndarray, npt: int = 512
) -> Tuple[np.ndarray, np.ndarray]:
"""
Recursive filter-design of an arbritrary frequency response using the
modified Yule-Walker method [1].
Expand Down

0 comments on commit 018419a

Please sign in to comment.