

def test_predictSNR_1(self):
    'Test function for predictSNR() 1/3'
    snr_ref = [(- 32.3447), (- 22.3447), (- 12.3447), (- 2.3447), 7.6553, 17.6553, 27.6553, 37.6552, 47.6545, 57.6475, 67.5768, 72.4043, 76.8266, 77.5913, 78.2773, 78.8451, 79.2116, 79.0974, (- np.Inf), (- np.Inf), (- np.Inf), (- np.Inf), (- np.Inf)]
    amp_ref = [(- 120.0), (- 110.0), (- 100.0), (- 90.0), (- 80.0), (- 70.0), (- 60.0), (- 50.0), (- 40.0), (- 30), (- 20), (- 15), (- 10), (- 9), (- 8), (- 7), (- 6), (- 5), (- 4), (- 3), (- 2), (- 1), 0]
    k0_ref = [1.6289, 1.6289, 1.6289, 1.6289, 1.6289, 1.6289, 1.6289, 1.6289, 1.6288, 1.6283, 1.6227, 1.6088, 1.5596, 1.5383, 1.5088, 1.4663, 1.4003, 1.2747, 0.0, 0.0, 0.0, 0.0, 0.0]
    k1_ref = [1.6289, 1.6289, 1.6289, 1.6289, 1.6289, 1.6289, 1.6289, 1.6289, 1.6287, 1.6274, 1.6142, 1.5819, 1.4752, 1.4326, 1.3768, 1.3025, 1.1995, 1.0387, 0.3706, 0.0, 0.0, 0.0, 0.0]
    sigma_e2_ref = [0.3634, 0.3634, 0.3634, 0.3634, 0.3634, 0.3634, 0.3634, 0.3634, 0.3634, 0.3634, 0.3634, 0.3631, 0.3607, 0.3591, 0.3566, 0.3525, 0.3459, 0.3352, 0.3178, 0.0, 0.0, 0.0, 0.0]
    order = 5
    osr = 32
    f0 = 0
    Hinf = 1.5
    ntf = ds.synthesizeNTF(order, osr, 2, Hinf, f0)
    (snr_pred, amp_pred, k0, k1, sigma_e2) = ds.predictSNR(ntf, osr, None, f0)
    for check in (np.isinf, np.isnan):
        i = check(snr_ref)
        snr_ref = np.delete(snr_ref, np.where(i))
        amp_ref = np.delete(amp_ref, np.where(i))
        i = check(snr_pred)
        snr_pred = np.delete(snr_pred, np.where(i))
        amp_pred = np.delete(amp_pred, np.where(i))
    self.assertTrue(np.allclose(snr_pred, snr_ref, atol=0.01, rtol=0.001))
    self.assertTrue(np.allclose(amp_pred, amp_ref, atol=0.01, rtol=0.0005))
    self.assertTrue(np.allclose(k0, k0_ref, atol=0.001, rtol=0.01))
    self.assertTrue(np.allclose(k1, k1_ref, atol=0.001, rtol=0.5))
    self.assertTrue(np.allclose(sigma_e2, sigma_e2_ref, atol=0.001, rtol=0.01))

dataset/ETHPy150Open ggventurini/python-deltasigma/deltasigma/tests/test_predictSNR.py TestPredictSNR.test_predictSNR_1/original