Skip to content

Commit

Permalink
Rename design_multirate_fir() to multirate_fir()
Browse files Browse the repository at this point in the history
Fixes #416
  • Loading branch information
mhostetter committed Jul 19, 2024
1 parent d2a9b42 commit 6c5e434
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 33 deletions.
14 changes: 7 additions & 7 deletions src/sdr/_filter/_design_multirate.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


@export
def design_multirate_fir(
def multirate_fir(
interpolation: int,
decimation: int = 1,
polyphase_order: int = 23,
Expand All @@ -41,13 +41,13 @@ def design_multirate_fir(
.. ipython:: python
h = sdr.design_multirate_fir(11, 3)
h = sdr.multirate_fir(11, 3)
@savefig sdr_design_multirate_fir_1.png
@savefig sdr_multirate_fir_1.png
plt.figure(); \
sdr.plot.impulse_response(h);
@savefig sdr_design_multirate_fir_2.png
@savefig sdr_multirate_fir_2.png
plt.figure(); \
sdr.plot.magnitude_response(h);
Expand Down Expand Up @@ -96,7 +96,7 @@ def design_multirate_fir(
return h


def design_multirate_fir_linear(rate: int) -> npt.NDArray[np.float64]:
def multirate_fir_linear(rate: int) -> npt.NDArray[np.float64]:
r"""
The multirate filter is designed to linearly interpolate between samples.
Expand All @@ -109,7 +109,7 @@ def design_multirate_fir_linear(rate: int) -> npt.NDArray[np.float64]:
return h


def design_multirate_fir_linear_matlab(rate: int) -> npt.NDArray[np.float64]:
def multirate_fir_linear_matlab(rate: int) -> npt.NDArray[np.float64]:
r"""
The multirate filter is designed to linearly interpolate between samples.
Expand All @@ -122,7 +122,7 @@ def design_multirate_fir_linear_matlab(rate: int) -> npt.NDArray[np.float64]:
return h


def design_multirate_fir_zoh(rate: int) -> npt.NDArray[np.float64]:
def multirate_fir_zoh(rate: int) -> npt.NDArray[np.float64]:
"""
The multirate filter is designed to be a zero-order hold.
Expand Down
36 changes: 18 additions & 18 deletions src/sdr/_filter/_polyphase.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@

from .._helper import convert_output, export, verify_arraylike, verify_bool, verify_literal, verify_scalar
from ._design_multirate import (
design_multirate_fir,
design_multirate_fir_linear,
design_multirate_fir_linear_matlab,
design_multirate_fir_zoh,
multirate_fir,
multirate_fir_linear,
multirate_fir_linear_matlab,
multirate_fir_zoh,
polyphase_decompose,
)
from ._fir import FIR
Expand Down Expand Up @@ -640,7 +640,7 @@ def __init__(
interpolation: The interpolation rate $P$.
taps: The prototype filter design specification.
- `"kaiser"`: The prototype filter is designed using :func:`~sdr.design_multirate_fir()`
- `"kaiser"`: The prototype filter is designed using :func:`~sdr.multirate_fir()`
with arguments `interpolation` and 1.
- `"linear"`: The prototype filter is designed to linearly interpolate between samples.
The filter coefficients are a length-$2P$ linear ramp $\frac{1}{P} [0, ..., P-1, P, P-1, ..., 1]$.
Expand Down Expand Up @@ -670,13 +670,13 @@ def __init__(
else:
self._method = verify_literal(taps, ["kaiser", "linear", "linear-matlab", "zoh"])
if taps == "kaiser":
taps = design_multirate_fir(interpolation, 1, polyphase_order, atten)
taps = multirate_fir(interpolation, 1, polyphase_order, atten)
elif taps == "linear":
taps = design_multirate_fir_linear(interpolation)
taps = multirate_fir_linear(interpolation)
elif taps == "linear-matlab":
taps = design_multirate_fir_linear_matlab(interpolation)
taps = multirate_fir_linear_matlab(interpolation)
elif taps == "zoh":
taps = design_multirate_fir_zoh(interpolation)
taps = multirate_fir_zoh(interpolation)

super().__init__(interpolation, taps, input="hold", output="top-to-bottom", streaming=streaming)

Expand Down Expand Up @@ -818,7 +818,7 @@ def __init__(
decimation: The decimation rate $Q$.
taps: The prototype filter design specification.
- `"kaiser"`: The prototype filter is designed using :func:`~sdr.design_multirate_fir()`
- `"kaiser"`: The prototype filter is designed using :func:`~sdr.multirate_fir()`
with arguments 1 and `decimation`.
- `npt.ArrayLike`: The prototype filter feedforward coefficients $h[n]$.
Expand All @@ -836,7 +836,7 @@ def __init__(
taps = verify_arraylike(taps, atleast_1d=True, ndim=1)
else:
self._method = verify_literal(taps, ["kaiser"])
taps = design_multirate_fir(1, decimation, polyphase_order, atten)
taps = multirate_fir(1, decimation, polyphase_order, atten)

super().__init__(decimation, taps, input="bottom-to-top", output="sum", streaming=streaming)

Expand Down Expand Up @@ -1004,7 +1004,7 @@ def __init__(
decimation: The decimation rate $Q$.
taps: The prototype filter design specification.
- `"kaiser"`: The prototype filter is designed using :func:`~sdr.design_multirate_fir()`
- `"kaiser"`: The prototype filter is designed using :func:`~sdr.multirate_fir()`
with arguments `interpolation` and `decimation`.
- `"linear"`: The prototype filter is designed to linearly interpolate between samples.
The filter coefficients are a length-$2P$ linear ramp $\frac{1}{P} [0, ..., P-1, P, P-1, ..., 1]$.
Expand Down Expand Up @@ -1032,15 +1032,15 @@ def __init__(
else:
self._method = verify_literal(taps, ["kaiser", "linear", "linear-matlab", "zoh"])
if taps == "kaiser":
taps = design_multirate_fir(interpolation, decimation, polyphase_order, atten)
taps = multirate_fir(interpolation, decimation, polyphase_order, atten)
else:
verify_scalar(interpolation, int=True, exclusive_min=1)
if taps == "linear":
taps = design_multirate_fir_linear(interpolation)
taps = multirate_fir_linear(interpolation)
elif taps == "linear-matlab":
taps = design_multirate_fir_linear_matlab(interpolation)
taps = multirate_fir_linear_matlab(interpolation)
elif taps == "zoh":
taps = design_multirate_fir_zoh(interpolation)
taps = multirate_fir_zoh(interpolation)

if interpolation == 1:
# PolyphaseFIR configured like Decimator
Expand Down Expand Up @@ -1210,7 +1210,7 @@ def __init__(
channels: The number of channels $C$.
taps: The prototype filter design specification.
- `"kaiser"`: The prototype filter is designed using :func:`~sdr.design_multirate_fir()`
- `"kaiser"`: The prototype filter is designed using :func:`~sdr.multirate_fir()`
with arguments 1 and `rate`.
- `npt.ArrayLike`: The prototype filter feedforward coefficients $h[n]$.
Expand All @@ -1228,7 +1228,7 @@ def __init__(
taps = verify_arraylike(taps, atleast_1d=True, ndim=1)
else:
self._method = verify_literal(taps, ["kaiser"])
taps = design_multirate_fir(1, channels, polyphase_order, atten)
taps = multirate_fir(1, channels, polyphase_order, atten)

super().__init__(channels, taps, input="bottom-to-top", output="all", streaming=streaming)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def test_3_1():
MATLAB:
>> transpose(designMultirateFIR(3, 1))
"""
h = sdr.design_multirate_fir(3, 1)
h = sdr.multirate_fir(3, 1)
h_truth = np.array(
[
0,
Expand Down Expand Up @@ -93,7 +93,7 @@ def test_1_3():
MATLAB:
>> transpose(designMultirateFIR(1, 3))
"""
h = sdr.design_multirate_fir(1, 3)
h = sdr.multirate_fir(1, 3)
h_truth = np.array(
[
0,
Expand Down Expand Up @@ -178,7 +178,7 @@ def test_3_2():
MATLAB:
>> transpose(designMultirateFIR(3, 2))
"""
h = sdr.design_multirate_fir(3, 2)
h = sdr.multirate_fir(3, 2)
h_truth = np.array(
[
0,
Expand Down Expand Up @@ -263,7 +263,7 @@ def test_2_3():
MATLAB:
>> transpose(designMultirateFIR(2, 3))
"""
h = sdr.design_multirate_fir(2, 3)
h = sdr.multirate_fir(2, 3)
h_truth = np.array(
[
0,
Expand Down Expand Up @@ -324,7 +324,7 @@ def test_3_2_20():
MATLAB:
>> transpose(designMultirateFIR(3, 2, 20))
"""
h = sdr.design_multirate_fir(3, 2, polyphase_order=39)
h = sdr.multirate_fir(3, 2, polyphase_order=39)
h_truth = np.array(
[
0,
Expand Down Expand Up @@ -457,7 +457,7 @@ def test_2_3_20():
MATLAB:
>> transpose(designMultirateFIR(2, 3, 20))
"""
h = sdr.design_multirate_fir(2, 3, polyphase_order=39)
h = sdr.multirate_fir(2, 3, polyphase_order=39)
h_truth = np.array(
[
-0.000036875262276,
Expand Down Expand Up @@ -551,7 +551,7 @@ def test_3_2_15_120():
MATLAB:
>> transpose(designMultirateFIR(3, 2, 15, 120))
"""
h = sdr.design_multirate_fir(3, 2, polyphase_order=29, atten=120)
h = sdr.multirate_fir(3, 2, polyphase_order=29, atten=120)
h_truth = np.array(
[
0,
Expand Down Expand Up @@ -654,7 +654,7 @@ def test_2_3_15_120():
MATLAB:
>> transpose(designMultirateFIR(2, 3, 15, 120))
"""
h = sdr.design_multirate_fir(2, 3, polyphase_order=29, atten=120)
h = sdr.multirate_fir(2, 3, polyphase_order=29, atten=120)
h_truth = np.array(
[
0,
Expand Down

0 comments on commit 6c5e434

Please sign in to comment.