Skip to content

Commit

Permalink
Add unit tests for sdr.downsample()
Browse files Browse the repository at this point in the history
  • Loading branch information
mhostetter committed Aug 19, 2023
1 parent 7752ffa commit e2bc26f
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/dsp/test_downsample.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import numpy as np
import pytest

import sdr


def test_exceptions():
x = np.random.randn(40)

with pytest.raises(TypeError):
# Rate must be an integer
sdr.downsample(x, 4.0)
with pytest.raises(ValueError):
# Rate must be positive
sdr.downsample(x, 0)


def test_1():
"""
Matlab:
>> x = 0:39;
>> downsample(x, 4)'
"""
x = np.arange(40)
y = sdr.downsample(x, 4)
y_truth = np.array([0, 4, 8, 12, 16, 20, 24, 28, 32, 36])
assert np.array_equal(y, y_truth)

0 comments on commit e2bc26f

Please sign in to comment.