-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7752ffa
commit e2bc26f
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |