Please replace trellis = cc.Trellis(M, generator_matrix) # Trellis structure by trellis = cc.Trellis(np.array([M]), generator_matrix) # Trellis structure, or so it seems.
AttributeError Traceback (most recent call last)
<ipython-input-5-d8ad681885c7> in <module>
3 m = np.array([L-1]) # number of delay elements
4 generator_matrix = np.array([[0o171, 0o133]]) # generator branches
----> 5 trellis = cc.Trellis([M], generator_matrix) # Trellis structure
<ME>/CommPy/commpy/channelcoding/convcode.py in __init__(self, memory, g_matrix, feedback, code_type, polynomial_format)
120 self.code_type = code_type
121
--> 122 self.total_memory = memory.sum()
123 self.number_states = pow(2, self.total_memory)
124 self.number_inputs = pow(2, self.k)
AttributeError: 'list' object has no attribute 'sum'
import numpy as np
import commpy.channelcoding.convcode as cc
import commpy.modulation as modulation
def BER_calc(a, b):
num_ber = np.sum(np.abs(a - b))
ber = np.mean(np.abs(a - b))
return int(num_ber), ber
N = 100000 #number of symbols per the frame
message_bits = np.random.randint(0, 2, N) # message
M = 4 # modulation order (QPSK)
k = np.log2(M) #number of bit per modulation symbol
modem = modulation.PSKModem(M) # M-PSK modem initialization
trellis = cc.Trellis(M, generator_matrix) # Trellis structure
rate = 1/2 # code rate
L = 7 # constraint length
m = np.array([L-1]) # number of delay elements
generator_matrix = np.array([[0o171, 0o133]]) # generator branches
trellis = cc.Trellis(M, generator_matrix) # Trellis structure
README tutorial is broken
Please replace
trellis = cc.Trellis(M, generator_matrix) # Trellis structure
bytrellis = cc.Trellis(np.array([M]), generator_matrix) # Trellis structure
, or so it seems.