def test_flip(self, adjust, shiftN): Np = 2**15-1 N = 2*Np s = signals.SignalQAMGrayCoded(16, N, bitclass=signals.PRBSBits) sig = s[0] syms = s.symbols[0] syms2 = np.roll(syms, shift=shiftN) (tx, rx), acm = ber_functions.sync_and_adjust(syms, syms2, adjust=adjust) npt.assert_allclose(tx, rx) (tx, rx), acm = ber_functions.sync_and_adjust(syms2, syms, adjust=adjust) npt.assert_allclose(tx, rx)
def test_slices_length(self, rx_longer, adjust): x = np.arange(1000.) xx = np.tile(x, 3) y = xx[11:1000+3*11] y_equal = xx[11:1000+1*11] if rx_longer is None: tx = x rx = y_equal else: if adjust == "tx": if rx_longer: rx = y tx = x else: rx = x tx = y elif adjust == "rx": if rx_longer: rx = y tx = x else: rx = x tx = y (tx, rx), acm = ber_functions.sync_and_adjust(tx, rx, adjust=adjust) assert tx.shape == rx.shape
def test_slices(self, rx_longer, adjust): x = np.arange(1000.) xx = np.tile(x, 3) y = xx[110:1000 + 3 * 110] ym = xx[110:1000 - 3 * 110] y_equal = xx[110:1000 + 1 * 110] if rx_longer is None: tx = x rx = y_equal else: if adjust == "tx": if rx_longer: rx = y tx = x else: rx = ym tx = x elif adjust == "rx": if rx_longer: rx = x tx = ym else: rx = x tx = y (tx, rx), acm = ber_functions.sync_and_adjust(tx, rx, adjust=adjust) npt.assert_array_almost_equal(tx, rx)
def test_rotated_and_diff_length(self, adjust, tx_i, rx_i, N1, N2, shiftN): Np = 2**15-1 N = 2*Np s = signals.SignalQAMGrayCoded(16, N, bitclass=signals.PRBSBits) sig = s[0] syms = s.symbols[0] syms2 = np.roll(syms, shift=shiftN) (tx, rx), acm = ber_functions.sync_and_adjust(syms[:N1]*1j**tx_i, syms2[:N2]*1j**rx_i, adjust=adjust) npt.assert_allclose(tx, rx)
def test_length(self, N1, N2, adjust): sig = self.s[0] N = self.s.shape[1] syms = self.s.symbols[0] (tx, rx), acm = ber_functions.sync_and_adjust(sig[:N1], sig[:N2], adjust=adjust) if N1 is None and adjust == "tx": assert (tx.shape[0] == N2) and (rx.shape[0] == N2) elif N2 is None and adjust == "rx": assert (tx.shape[0] == N1) and (rx.shape[0] == N1) else: assert (tx.shape[0] == N) and (rx.shape[0] == N)
def test_slices_data_rx(self, N, tx_longer): s = signals.SignalQAMGrayCoded(4, 2**16)[0] ss = np.tile(s, 3) if tx_longer is None: y = ss[N:2**16+N] elif tx_longer: y = ss[N:2**16+2*N] else: y = ss[N:2**16-2*N] (tx, rx), acm = ber_functions.sync_and_adjust(y, s, adjust="rx") npt.assert_array_almost_equal(tx,rx)
def test_length_with_shift(self, N0, shiftN, adjust): sig = self.s[0] N = self.s.shape[1] N1, N2 = N0 sign = np.roll(sig, shiftN) (tx, rx), acm = ber_functions.sync_and_adjust(sig[:N1], sign[:N2], adjust=adjust) if N1 is None and adjust is "tx": assert (tx.shape[0] == N2) and (rx.shape[0] == N2) elif N2 is None and adjust is "rx": assert (tx.shape[0] == N1) and (rx.shape[0] == N1) else: assert (tx.shape[0] == N) and (rx.shape[0] == N)