Skip to content

Commit 8740ce8

Browse files
prsudheerakou97
authored andcommitted
Number of elements in conv_encode is declared using if-else condition to avoid extra zeros in the output of encoded bits without puncturing
1 parent fc163ad commit 8740ce8

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

commpy/channelcoding/convcode.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@
88
import matplotlib.patches as mpatches
99
import matplotlib.pyplot as plt
1010
import numpy as np
11-
from matplotlib.collections import PatchCollection
12-
1311
from commpy.utilities import dec2bitarray, bitarray2dec, hamming_dist, euclid_dist
12+
from matplotlib.collections import PatchCollection
1413

1514
__all__ = ['Trellis', 'conv_encode', 'viterbi_decode']
1615

@@ -381,7 +380,10 @@ def conv_encode(message_bits, trellis, termination = 'term', puncture_matrix=Non
381380
number_outbits = int(number_inbits/rate)
382381

383382
outbits = np.zeros(number_outbits, 'int')
384-
p_outbits = np.zeros(int(number_outbits*
383+
if puncture_matrix is not None:
384+
p_outbits = np.zeros(number_outbits)
385+
else:
386+
p_outbits = np.zeros(int(number_outbits*
385387
puncture_matrix[0:].sum()/np.size(puncture_matrix, 1)), 'int')
386388
next_state_table = trellis.next_state_table
387389
output_table = trellis.output_table

0 commit comments

Comments
 (0)