-
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
7f6da9d
commit 4075053
Showing
1 changed file
with
62 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,62 @@ | ||
import numpy as np | ||
|
||
import sdr | ||
|
||
|
||
def test_same(): | ||
snr1 = np.arange(-40, 40 + 10, 10) | ||
snr = sdr.composite_snr(snr1, snr1) | ||
snr_truth = np.array( | ||
[ | ||
-76.99056855, | ||
-56.99837726, | ||
-37.07570176, | ||
-17.7815125, | ||
-1.76091259, | ||
9.78810701, | ||
19.97833938, | ||
29.99782907, | ||
39.99978286, | ||
] | ||
) | ||
assert np.allclose(snr, snr_truth) | ||
|
||
|
||
def test_different_n20(): | ||
snr1 = np.arange(-40, 40 + 10, 10) | ||
snr2 = -20 | ||
snr = sdr.composite_snr(snr1, snr2) | ||
snr_truth = np.array( | ||
[ | ||
-57.03334375, | ||
-47.0372116, | ||
-37.07570176, | ||
-27.44292983, | ||
-20.02166062, | ||
-17.40757323, | ||
-17.03334375, | ||
-16.9940842, | ||
-16.99013866, | ||
] | ||
) | ||
assert np.allclose(snr, snr_truth) | ||
|
||
|
||
def test_different_20(): | ||
snr1 = np.arange(-40, 40 + 10, 10) | ||
snr2 = 20 | ||
snr = sdr.composite_snr(snr1, snr2) | ||
snr_truth = np.array( | ||
[ | ||
-37.03291808, | ||
-27.03295678, | ||
-17.03334375, | ||
-7.0372116, | ||
2.92429824, | ||
12.55707017, | ||
19.97833938, | ||
22.59242677, | ||
22.96665625, | ||
] | ||
) | ||
assert np.allclose(snr, snr_truth) |