Skip to content

Commit

Permalink
Test phase changes for QPSK
Browse files Browse the repository at this point in the history
Numerically check where the phase changes in the output signal and assert that
the same locations are found in the second output argument.
  • Loading branch information
jaidevd committed Mar 1, 2016
1 parent ac648af commit 369265a
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions tftb/generators/tests/test_analytic_signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

import unittest
import numpy as np
from scipy import angle, unwrap
from scipy.stats import mode
from tftb.tests.base import TestBase
from tftb.generators import analytic_signals as ana

Expand Down Expand Up @@ -44,11 +46,16 @@ def test_anapulse(self):

def test_anaqpsk(self):
"""Test quaternary PSK signal."""
# FIXME: Better tests for analytical QPSK
# Currently only the analyticity of the analytical QPSK signal is being
# tested.
signal, pm0 = ana.anaqpsk(512, 64, 0.05)
signal, phases = ana.anaqpsk(512, 64, 0.25)
self.assert_is_analytic(signal)
# Count discontinuities in the signal and the phases and assert that
# they appear in the same locations
uphase = unwrap(angle(signal))
dphase = np.diff(uphase)
base_value = mode(dphase)[0][0]
signal_phase_change = np.abs(dphase - base_value) > 0.0001
ideal_phase_change = np.diff(phases) != 0
np.testing.assert_allclose(signal_phase_change, ideal_phase_change)

def test_anastep(self):
"""Test analytic unit step signal."""
Expand Down

0 comments on commit 369265a

Please sign in to comment.