Skip to content

Commit 1155968

Browse files
authored
Merge pull request #78 from eSoares/fix_wrap_as_tupple
Fix issue #76
2 parents bb0fd40 + 9fd6974 commit 1155968

File tree

7 files changed

+29
-11
lines changed

7 files changed

+29
-11
lines changed

commpy/channelcoding/convcode.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,9 @@ def _where_c(inarray, rows, cols, search_value, index_array):
573573

574574

575575
@functools.lru_cache(maxsize=128, typed=False)
576-
def _compute_branch_metrics(decoding_type, r_codeword, i_codeword_array):
576+
def _compute_branch_metrics(decoding_type, _r_codeword: tuple, _i_codeword_array: tuple):
577+
r_codeword = np.array(_r_codeword)
578+
i_codeword_array = np.array(_i_codeword_array)
577579
if decoding_type == 'hard':
578580
return hamming_dist(r_codeword.astype(int), i_codeword_array.astype(int))
579581
elif decoding_type == 'soft':

commpy/channelcoding/tests/test_convcode.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ def test_viterbi_decode(self):
131131

132132
@dec.slow
133133
def test_conv_encode_viterbi_decode(self):
134+
# Set seed
135+
seed(17121996)
136+
134137
niters = 10
135138
blocklength = 1000
136139

@@ -176,6 +179,5 @@ def test_conv_encode_viterbi_decode(self):
176179

177180

178181
if __name__ == "__main__":
179-
seed(17121996)
180182
run_module_suite()
181183

commpy/tests/test_channels.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ def check(chan):
4848
err_msg='SISO channel as more than 1 Tx')
4949

5050
def test_fading(self):
51+
# Set seed
52+
seed(17121996)
53+
5154
def check_chan_gain(mod, chan):
5255
msg = choice(mod, self.msg_length)
5356
chan.propagate(msg)
@@ -121,6 +124,9 @@ def check_chan_gain(mod, chan):
121124
err_msg='Wrong channel variance with real channel')
122125

123126
def test_noise_generation(self):
127+
# Set seed
128+
seed(17121996)
129+
124130
def check_noise(mod, chan, corrected_SNR_lin):
125131
msg = choice(mod, self.msg_length)
126132
chan.propagate(msg)
@@ -267,6 +273,9 @@ def __init__(self):
267273
super(TestMIMOFading, self).__init__()
268274

269275
def do(self, nb_tx, nb_rx):
276+
# Set seed
277+
seed(17121996)
278+
270279
def check_chan_gain(mod, chan):
271280
msg = choice(mod, self.msg_length)
272281
chan.propagate(msg)
@@ -408,7 +417,7 @@ def __init__(self):
408417
def do(self, nb_tx, nb_rx):
409418
chan = MIMOFlatChannel(nb_tx, nb_rx, 0)
410419

411-
# Text raising of ValueError
420+
# Test raising of ValueError
412421
with assert_raises(ValueError):
413422
chan.specular_compo(0, -1, 0, 1)
414423
with assert_raises(ValueError):
@@ -429,6 +438,9 @@ def __init__(self):
429438
super(TestMIMONoiseGeneration, self).__init__()
430439

431440
def do(self, nb_tx, nb_rx):
441+
# Set seed
442+
seed(17121996)
443+
432444
def check_noise(mod, chan, corrected_SNR_lin):
433445
msg = choice(mod, self.msg_length)
434446
chan.propagate(msg)
@@ -505,6 +517,9 @@ def __init__(self):
505517
super(TestMIMOkFactor, self).__init__()
506518

507519
def do(self, nb_tx, nb_rx):
520+
# Set seed
521+
seed(17121996)
522+
508523
prod_nb = nb_tx * nb_rx
509524

510525
# Real channel
@@ -533,5 +548,4 @@ def do(self, nb_tx, nb_rx):
533548

534549

535550
if __name__ == "__main__":
536-
seed(17121996)
537551
run_module_suite()

commpy/tests/test_links.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515

1616
@dec.slow
1717
def test_link_performance():
18+
# Set seed
19+
seed(17121996)
20+
1821
# Apply link_performance to SISO QPSK and AWGN channel
1922
QPSK = QAMModem(4)
2023

@@ -46,5 +49,4 @@ def receiver(y, h, constellation, noise_var):
4649

4750

4851
if __name__ == "__main__":
49-
seed(17121996)
5052
run_module_suite()

commpy/tests/test_modulation.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515

1616
@dec.slow
1717
def test_bit_lvl_repr():
18-
# Test the BLR by comparing the performance of a receiver with and without it.
18+
# Set seed
19+
seed(17121996)
1920

21+
# Test the BLR by comparing the performance of a receiver with and without it.
2022
qam = QAMModem(4)
2123

2224
nb_rx = 2
@@ -143,5 +145,4 @@ def do_custom(self, modem):
143145

144146

145147
if __name__ == "__main__":
146-
seed(17121996)
147148
run_module_suite()

commpy/tests/test_sequences.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# License: BSD 3-Clause
33

44
from numpy import array
5-
from numpy.random import seed
65
from numpy.testing import run_module_suite, assert_raises, assert_equal
76

87
from commpy.sequences import pnsequence
@@ -20,6 +19,6 @@ def test_pnsequence():
2019
assert_equal(pnsequence(4, (0, 0, 1, 1), array((1, 1, 0, 1)), 7), array((1, 1, 0, 0, 1, 0, 1), int),
2120
err_msg='Pseudo-noise sequence is not the one expected.')
2221

22+
2323
if __name__ == "__main__":
24-
seed(17121996)
2524
run_module_suite()

commpy/tests/test_utilities.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# License: BSD 3-Clause
33

44
from numpy import array
5-
from numpy.random import seed
65
from numpy.testing import run_module_suite, assert_array_equal
76

87
from commpy.utilities import dec2bitarray
@@ -15,5 +14,4 @@ def test_dec2bitarray():
1514

1615

1716
if __name__ == "__main__":
18-
seed(17121996)
1917
run_module_suite()

0 commit comments

Comments
 (0)