Skip to content

Commit ca8d807

Browse files
committed
Update as requested in the review. Thanks for your advise @veeresht.
1 parent d52bd2f commit ca8d807

File tree

6 files changed

+25
-21
lines changed

6 files changed

+25
-21
lines changed

commpy/channelcoding/tests/test_ldpc.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
# Authors: Veeresh Taranalli <veeresht@gmail.com>
22
# License: BSD 3-Clause
33

4+
import os
5+
6+
from nose.plugins.attrib import attr
47
from numpy import array, sqrt, zeros
58
from numpy.random import randn
69
from numpy.testing import assert_allclose
10+
711
from commpy.channelcoding.ldpc import get_ldpc_code_params, ldpc_bp_decode
812
from commpy.utilities import hamming_dist
9-
import os
1013

11-
from nose.plugins.attrib import attr
1214

1315
@attr('slow')
1416
class TestLDPCCode(object):
@@ -59,4 +61,4 @@ def test_ldpc_bp_decode(self):
5961
fer_array_test[idx] = float(fer_cnt_bp)/(iter_cnt+1)
6062
break
6163

62-
assert_allclose(fer_array_test, fer_array_ref, rtol=2e-1, atol=0)
64+
assert_allclose(fer_array_test, fer_array_ref, rtol=.5, atol=0)

commpy/examples/plotConsModem.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
# Example constellation plot of Modem
88
# =============================================================================
99

10-
# PSK corresponding to PSKModem for 4 bits
10+
# Constellation corresponding to PSKModem for 4 bits per symbols
1111
psk = PSKModem(16)
1212
psk.plotCons()
1313

14-
# QAM corresponding to QAMModem for 2bits
15-
Qam = QAMModem(4)
16-
Qam.plotCons()
14+
# Constellation corresponding to QAMModem for 2 bits per symbols
15+
qam = QAMModem(4)
16+
qam.plotCons()

commpy/links.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010
:toctree: generated/
1111
1212
link_performance -- Estimate the BER performance of a link model with Monte Carlo simulation.
13-
linkModel -- Link model object.
13+
LinkModel -- Link model object.
1414
"""
1515
from __future__ import division # Python 2 compatibility
1616

1717
import numpy as np
1818

1919
from commpy.channels import MIMOFlatChannel
2020

21-
__all__ = ['link_performance', 'linkModel']
21+
__all__ = ['link_performance', 'LinkModel']
2222

2323

2424
def link_performance(link_model, SNRs, send_max, err_min, send_chunk=None, code_rate=1):
@@ -89,7 +89,7 @@ def link_performance(link_model, SNRs, send_max, err_min, send_chunk=None, code_
8989
return BERs
9090

9191

92-
class linkModel:
92+
class LinkModel:
9393
"""
9494
Construct a link model.
9595

commpy/modulation.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@
2121
from itertools import product
2222

2323
import matplotlib.pyplot as plt
24-
from commpy.utilities import bitarray2dec, dec2bitarray
2524
from numpy import arange, array, zeros, pi, cos, sin, sqrt, log2, argmin, \
2625
hstack, repeat, tile, dot, shape, concatenate, exp, \
2726
log, vectorize, empty, eye, kron
2827
from numpy.fft import fft, ifft
2928
from numpy.linalg import qr, norm
3029

30+
from commpy.utilities import bitarray2dec, dec2bitarray
31+
3132
__all__ = ['PSKModem', 'QAMModem', 'ofdm_tx', 'ofdm_rx', 'mimo_ml', 'kbest', 'bit_lvl_repr']
3233

3334

@@ -100,7 +101,7 @@ def demodulate(self, input_symbols, demod_type, noise_var=0):
100101

101102
return demod_bits
102103

103-
def plotCons(self):
104+
def plot_constellation(self):
104105
""" Plot the constellation """
105106
# init some arrays
106107
beta = self.num_bits_symbol

commpy/tests/test_links.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from scipy.special import erfc
1010

1111
from commpy.channels import MIMOFlatChannel, SISOFlatChannel
12-
from commpy.links import link_performance, linkModel
12+
from commpy.links import link_performance, LinkModel
1313
from commpy.modulation import QAMModem, kbest
1414

1515

@@ -20,7 +20,7 @@ def test_link_performance():
2020

2121
def receiver(y, h, constellation):
2222
return QPSK.demodulate(y, 'hard')
23-
model = linkModel(QPSK.modulate, SISOFlatChannel(fading_param=(1 + 0j, 0)), receiver,
23+
model = LinkModel(QPSK.modulate, SISOFlatChannel(fading_param=(1 + 0j, 0)), receiver,
2424
QPSK.num_bits_symbol, QPSK.constellation, QPSK.Es)
2525

2626
BERs = link_performance(model, range(0, 9, 2), 600e4, 600)
@@ -35,7 +35,7 @@ def receiver(y, h, constellation):
3535

3636
def receiver(y, h, constellation):
3737
return QAM16.demodulate(kbest(y, h, constellation, 16), 'hard')
38-
model = linkModel(QAM16.modulate, RayleighChannel, receiver,
38+
model = LinkModel(QAM16.modulate, RayleighChannel, receiver,
3939
QAM16.num_bits_symbol, QAM16.constellation, QAM16.Es)
4040
SNRs = arange(0, 21, 5) + 10 * log10(QAM16.num_bits_symbol)
4141

commpy/tests/test_modulation.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
# Authors: Youness Akourim <akourim97@gmail.com>
22
# License: BSD 3-Clause
33

4-
from commpy.channels import MIMOFlatChannel
5-
from commpy.links import *
6-
from commpy.modulation import QAMModem, mimo_ml, bit_lvl_repr
74
from numpy import zeros, identity, arange, concatenate, log2, array
85
from numpy.random import seed
96
from numpy.testing import run_module_suite, assert_allclose, dec
107

8+
from commpy.channels import MIMOFlatChannel
9+
from commpy.links import *
10+
from commpy.modulation import QAMModem, mimo_ml, bit_lvl_repr
11+
1112

1213
@dec.slow
1314
def test_bit_lvl_repr():
@@ -35,13 +36,13 @@ def receiverWithoutBLR(y, H, cons):
3536
return qam.demodulate(mimo_ml(y, H, cons), 'hard')
3637

3738
MymodelWithoutBLR = \
38-
linkModel(qam.modulate, RayleighChannel, receiverWithoutBLR, qam.num_bits_symbol, qam.constellation, qam.Es)
39+
LinkModel(qam.modulate, RayleighChannel, receiverWithoutBLR, qam.num_bits_symbol, qam.constellation, qam.Es)
3940
MymodelWithBLR = \
40-
linkModel(qam.modulate, RayleighChannel, receiverWithBLR, qam.num_bits_symbol, qam.constellation, qam.Es)
41+
LinkModel(qam.modulate, RayleighChannel, receiverWithBLR, qam.num_bits_symbol, qam.constellation, qam.Es)
4142

4243
BERWithoutBLR = link_performance(MymodelWithoutBLR, SNR, 300e4, 300)
4344
BERWithBLR = link_performance(MymodelWithBLR, SNR, 300e4, 300)
44-
assert_allclose(BERWithoutBLR, BERWithBLR, rtol=0.25,
45+
assert_allclose(BERWithoutBLR, BERWithBLR, rtol=0.5,
4546
err_msg='bit_lvl_repr changes the performance')
4647

4748

0 commit comments

Comments
 (0)