Skip to content

Commit

Permalink
Add unit tests for composite_snr()
Browse files Browse the repository at this point in the history
  • Loading branch information
mhostetter committed May 16, 2024
1 parent 7f6da9d commit 4075053
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions tests/estimation/test_composite_snr.py
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)

0 comments on commit 4075053

Please sign in to comment.