-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit tests for
max_frequency_offset()
- Loading branch information
1 parent
19fc0d6
commit 3a61a50
Showing
1 changed file
with
31 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,31 @@ | ||
import numpy as np | ||
import pytest | ||
|
||
import sdr | ||
|
||
|
||
def test_exceptions(): | ||
with pytest.raises(ValueError): | ||
# CGL must be non-negative | ||
sdr.max_frequency_offset(-3, 1e-3) | ||
with pytest.raises(ValueError): | ||
# CGL must be non-negative | ||
sdr.max_frequency_offset([-3, 0, 3], 1e-3) | ||
|
||
|
||
def test_scalar(): | ||
assert sdr.max_frequency_offset(3, 1e-3) == pytest.approx(442.2433896262681) | ||
|
||
|
||
def test_cgl_vector(): | ||
f = sdr.max_frequency_offset([1, 2, 3, 4, 5], 1e3) | ||
f_truth = np.array([0.0002615, 0.00036547, 0.00044224, 0.00050444, 0.00055699]) | ||
assert isinstance(f, np.ndarray) | ||
assert np.allclose(f, f_truth) | ||
|
||
|
||
def test_freq_vector(): | ||
f = sdr.max_frequency_offset(3, [1e-3, 2e-3, 3e-3, 4e-3, 5e-3]) | ||
f_truth = np.array([442.24338963, 221.12169481, 147.41446321, 110.56084741, 88.44867793]) | ||
assert isinstance(f, np.ndarray) | ||
assert np.allclose(f, f_truth) |